The following program LOOKS to be working fine but not sure why is displaying wrong, when I input either F or C, it displays:
Degree Degree
celsius fahrenehit
------- ------------
nnn nnnn
sorry for the mess^^^. You should be able to just copy/paste and it should run for yaCode:#include <iostream> #include <iomanip> using namespace std; void primetest(int); int main () { int number; cout << "You have selected the prime option." << "\nEnter any number you wish to test."; cin >> number; primetest(number); return 0; } void convert (int tempmin, int tempmax, char choice) { if (choice == 'C' || choice == 'c') { const int step = 1; double fahren; int celsius; cout << "Degree Degrees\n" << "Celsius Fahrenheit\n" << "------- ----------\n"; celsius = tempmin; cout << setiosflags (ios :: showpoint) << setiosflags (ios :: fixed) << setprecision (2); while (celsius <=tempmax) { fahren = (9.0/5.0) * celsius + 32.0; cout << setw (4) << celsius << setw (13) << fahren << endl; celsius = celsius + step; } } else if (choice == 'f' || choice == 'F') { const int increase = 1; int fahren; double celsius; cout << "Degree Degrees\n" << "Fahrenheit Celsius\n" << "------ -------\n"; fahren = tempmin; cout << setiosflags (ios :: showpoint) << setiosflags (ios :: fixed) << setprecision (2); while (fahren <=tempmax) { celsius = (fahren-32) *(5.0/9.0); cout << setw (4) << fahren << setw (13) << celsius << endl; fahren = fahren + increase; cout << endl; } } }



LinkBack URL
About LinkBacks



CornedBee