So I finally I got this to work, but my problem is that it gets very messy when I try to print it as a chart. I have to print the output in a neat tabular format that minimizes the number of lines of output while remaining readable.
When I remove the endl in function displayFahrenheit() and function displayCelsius(), and I also uncomment the if statements, they still do not work appropriately and I am not sure what other way I should try this or if there is a specific way to print charts / matrix format in C++ ? ? ?
My code is the following:
#include <iostream>
using namespace std;
#include <iomanip>
#using std::setw;
#include "Temperatures.h"
// function fahrenheit returns the Fahrenheit equivalent of a Celsius temperature
double Temperatures::fahrenheit(int countCelsius)
{
return (((countCelsius * 9.00) / 5.00) + 32);
}
// function celsius returns the Celsius equivalent of a Fahrenheit temperature
double Temperatures::celsius(int countFahrenheit)
{
return ((countFahrenheit - 32) * (5.00/9.00));
}
// function displayFahrenheit uses a for loop to call the functions to calculate the Fahrenheit for Celsius 0 to 100
void Temperatures::displayFahrenheit()
{
cout << "Fahrenheit equivalents for Celsius 0 to 100 degrees are: \n";
for(int counter = 0; counter <= 100; counter++)
{
cout << counter << setw(5) << " " << setprecision(2) << showpoint << fixed << fahrenheit(counter)<< endl;
//if(counter % 10 == 0)
//cout << endl;
}
}
// function displayCelsius uses a for loop to call the functions to calculate the Celsius for Fahrenheit 32 to 212
void Temperatures::displayCelsius()
{
cout << "\nCelsius equivalents of Fahrenheit 32 to 212 degrees: \n";
for(int counter2 = 32; counter2 <= 212; counter2++)
{
cout << counter2 << setw(5) << " " << setprecision(2) << showpoint << fixed << celsius(counter2) << endl;
//if(counter2 % 18 ==0)
// cout << endl;
}
}