C++ flowchart help??

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");
}
Last edited on
Draw one in real life, or in a program?

What do you want it to be based on?
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>

using namespace std;

int main()
{
double f, c;
int select;

cout << "Please select from the following: " << endl;
cout << "1) Fahrenheit-to-Celsius" << endl;
cout << "2) Celsius-to-Fahrenheit" << endl;
cout << "Enter: ";
cin >> select;

if(action != 1 || action != 2)
{
while(action != 1 || action != 2)
{
cout<<"Valid options 1 or 2." << endl;
}
} 

else if(action == 1)
{
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
{
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; 
}
}
@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.
oh ok

take it step by step (or, sections of code) and show how they link together and brach off
Here's a flowchart I did in Google Docs' Drawing Editor: http://www.majhost.com/gallery/Karkuta/pics/flowchartweekfive.png

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.)

Here's another flowchart I did for computing the circumference and area for a circle: http://www.majhost.com/gallery/Karkuta/pics/flowchartweekseven.png
(This one is a little more complicated, involving functions.)
Last edited on
Topic archived. No new replies allowed.