My code below, as you can see I am doing a Menu, but it is mostly the FOR loop at the end is hat I am stuck on and I have tried count++, as you see throughout the FOR loop trying to get it loop but can't.
#include <iostream>
#include <cctype>
using namespace std;
int displayMenu();
char getMenuSelection(char &choice);
int getStartEndAndIncrement(int &start, int &end, int &increment);
int cToF(int start, int end, int increment, int &count);
int main ()
{
char choice;
int start = 0;
int end = 0;
int increment = 0;
int count = 0;
while(1)
{
displayMenu();
getMenuSelection(choice);
getStartEndAndIncrement(start, end, increment);
cToF( start, end, increment, count);
}
cin.ignore(2);
return(0);
}
int displayMenu()
{
cout << "\t\t\tTemperature Table Functions\n" << endl;
cout << "1. Press letter 'C' to go from Celcius to Fahrenheit " << endl;
cout << "2. Press letter 'F' to go from Fahrenheit to Celsius " << endl;
cout << "3. Press letter 'Q' to quit the program\n " << endl;
}
char getMenuSelection(char &choice)
{
cout << "Which choices would you like to try: " << endl;
cin >> choice;
choice = toupper(choice);
while(1)
{
if (choice == 'C' || choice == 'c' || choice == 'F' || choice == 'f')
{
return choice;
}
else if (choice == 'Q')
{
exit(1);
}
else
{
cout << "Invalid Choice. Must choose between: C, F, or Q: " << endl;
cin >> choice;
}
}
}
int getStartEndAndIncrement(int &start, int &end, int &increment)
{
cout << "What is the temperature you would like to start with: " << endl;
cin >> start;
cout << "What is the temperature you would like to end with: " << endl;
cin >> end;
cout << "What would you like to Increment the temeperature by: " << endl;
cin >> increment;
}
int cToF(int start, int end, int increment, int &count)
{
double fahrenheit;
for (count = start; count <= end; count = count + increment)
{
cout << count << " ";
for (count = start; count <= end; count = count + increment)
{
fahrenheit = (5.0 * (start - 32.0))/9.0;
}
cout << fahrenheit;
}
count++;
}

New Topic/Question
Reply
MultiQuote







|