Can someone help me draw a flowchart for this C++ program for temperature conversion (this is my first semester of taking programming)...thanks in advance!
#include<iostream>
using namespace std;
int main()
{
double f, c, select = 0;
cout << "Please select from the following: " << endl;
cout << "1) Fahrenheit-to-Celsius" << endl;
cout << "2) Celsius-to-Fahrenheit" << endl;
cout << "Enter: ";
cin >> select;
if (select == 1.0)
{
cout << " Enter temperature in Fahrenheit to convert to degrees Celsius: ";
cin >> f;
c = (f-32) * 5.0 / 9.0;
cout << "Equivalent in Celsius is: " << c << endl;
}
else if (select == 2.0)
{
cout <<" Enter temperature in Celsius to convert to degrees Fahrenheit: ";
cin >> c;
f = c*9.0/5.0 + 32;
cout << "Equivalent in Fahrenheit is: " << f << endl;
}
else
cout << "Valid options 1 or 2." << endl;
system("pause");
}
1-Put your code in between code blocks which are generated with <> button
2-make select an int
3-Why would you initialize select when you don't need to?
4-system("pause") is evil. this is why: http://www.gidnetwork.com/b-61.html try cin.get()
5-the last else statement is really quite, in my opinion, useless there. how about this:
@Ben Duncan it want to draw in real life...the assignment was originally to write a program that converts temperature between celsius and fahrenheit, and to draw a flowchart for it. So basically I just need a flowchart to describe how to convert celsius to fahrenheit and vise versa.
In flowcharting you ignore declarations, (variables, headers, etc.)
However if you're assigning a value to a variable, (like when you declare f,c, and select to 0,) you'd include that as a process. (The shape "sum = sum + num2Add" has.)
The slanted rectangle is for data, (eg; input from or output to the console.) The diamond is for Decision Control Structures, (usually an "if" statement.)