//Clifton Copeland
//Excercise 6.27
//This program outputs Fahrenheit and Celcius range charts.
//C = (F-32)*5/9
//F = C*9/5+32

#include <iostream>
using namespace std;
int cTable;
int fTable;


int main()
{
    
    cout << "Choose which table you would like to display." << endl;
    cout << "Press C for conversions to Celcius." << endl;
    cin >> cTable >> endl;
    cout << "Press F for conversions to Farenheit." << endl;
    cin >> fTable >> endl;
 
    
    return 0;

}

That's what I have so far. I know it's not much, but I am totally stuck on this. We didn't even touch on this in class last time due to lack of time. Now, we're supposed to create a program that prints charts showing F equiv of all C temps from 0-100 degrees. It's supposed to be printed in a neat tabular format. I'm totally at a loss where to begin with all of it.

If someone could possibly point me in the right direction I would so greatly appreciatte it. I need a table for C equivs of F temps, but if I could get an idea on one table type, I'm sure I could do the other. Formatting the output on the screen really has me totally confused.

Thank any who would be willing to help with this SO much!

-kahaj

Errrr, what are you stuck with? How to print in neat tabular form? Something like this?

Temp (deg C) | Temp (deg F)
--------------+---------------
    0.0       |  ...
    1.0       |  ...

This is what I have so far. I'm really stuck now. And yeah, printing it like you show is one thing I cannot figure out. I also can't figure out what I'm doing wrong that the program is doing what it is. :/

//Clifton Copeland
//Excercise 6.27
//This program outputs Fahrenheit and Celcius range charts.
//C = (F-32)*5/9
//F = C*9/5+32

#include <iostream>
#include <iomanip>
using std::cout;
using std::endl;
using std::setw;


int main()
{

double celc;
double fahr;
fahr = celc * (9.0/5.0) + 32;

    cout << "Below, you'll find a table containing Fahrenheit and Celcius conversions.\n\n";
    cout << "Celcius" << setw( 20 ) << "Fahrenheit" << endl;
    
     for ( celc = 0; celc >= 0; celc++ )
        {
         cout << celc << fahr << endl;
        }
    
    return 0;

}

Some things:

#include <iostream>
#include <iomanip>
using std::cout;
using std::endl;
using std::setw;

int main()
{
   cout << "Below, you'll find a table containing Fahrenheit and Celcius conversions.\n\n";
   cout << setw( 20 ) << "Celcius" << setw( 20 ) << "Fahrenheit" << '\n';

   for ( double celc = 0; celc < 100; celc++ )
   {
      double fahr = celc * (9.0/5.0) + 32;
      cout << setw( 20 ) << celc << setw( 20 ) << fahr << '\n';
   }
   return 0;
}

For the most part, if you want it to recalculate in the loop, you'll have to put the caluculation in the loop. This language doesn't read a formula and then later apply it to incoming data like that (well it could, sorta, if you used a function).

This article has been dead for over six months. Start a new discussion instead.