anyone willing to chat c++ ?

Goosemaster

Lifer
Apr 10, 2001
48,775
3
81
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
double celsius;
double fahrenheit;
char m ;
char n;

//program introduction. Asks for confirmation to continue
cout << "WELCOME TO THE ULTRACONVERTOR 3000, YOUR SOURCE FOR TEMPERATURE CONVERSION," << endl;
cout << "FUFILLING ALL YOUR TEMPERATRUE NEED SINCE 1955" << endl;
cout << "\nWOULD YOU LIKE ME TO CONVERT TEMPERATURES TODAY?" << endl;
cout << "TYPE YES OR NO TO CONTINUE" << endl;
cin >> m;

//decides whether they typed yes or no by simply checking the first letter
switch( m ) {
case 'y':
case 'Y':
cout << "\n\n\ngreat, let's get started!" << endl;
//if yes, the temp. program begins asking user for which task to proceed with
cout << "\n\nPlease select which type of conversion you would like to proceed with:" << endl;
cout << "a)Celsius to Fahrenheit \nb)Fahrenheit to Celsius \nc)I'm done" << endl;
cin >> n;

switch (n)

//first case executes the celsius to fahrenheit conversion module


//while loop that will repeat the program until I select option c
do

{

case 'a':
case 'A':
cout << "Let's get started!" << endl;
cout << "Please enter a celsius value." << endl;
cin >> celsius;

fahrenheit = ((9.0/5)*celsius) + 32;

cout << "the value you entered was " << celsius << endl;
cout << "that equals "<< fahrenheit << " degrees fahrenheit" << endl;
break;

//second case executes the fahrenheit to celsius conversion module
case 'b':
case 'B':
cout << "Let's get started!" << endl;
cout << "Please enter a fahrenheit value." << endl;
cin >> fahrenheit;

celsius = (5.0/9)*(fahrenheit - 32);

cout << "the value you entered was" << fahrenheit << endl;
cout << "that equals "<< fahrenheit << "celsius" << endl;


cout << "thank you for using the ULTRACONVERTOR 3000" << endl;

}

while ( n!= c)


cout << "thank you for using the ULTRACONVERTOR 3000" << endl;


//if not, the program identifies their answer as a no and the program ends
break;
case 'n':
case 'N':
cout << " too bad." << endl;
break;
default:
cout << "too bad" << endl;
break;

}



//fin
system ("PAUSE");

}

the bolded part is what is not working. I have chekced and EVERYTHING is working minus the while lopp which I just added
 

Goosemaster

Lifer
Apr 10, 2001
48,775
3
81
I want to createa while loop that cycles the program until I select option c to end it

not doing much :(

I am just playing around with c++. for homework I needed to make a simple converter but I am going all out. I will also find a way to put arrays to use if I can :evil:
 

JetBlack69

Diamond Member
Sep 16, 2001
4,580
1
0
Put this inside the do-while loop

cout << "\n\nPlease select which type of conversion you would like to proceed with:" << endl;
cout << "a)Celsius to Fahrenheit \nb)Fahrenheit to Celsius \nc)I'm done" << endl;
cin >> n;

switch (n)
 

Goosemaster

Lifer
Apr 10, 2001
48,775
3
81
great, let's get started!


Please select which type of conversion you would like to proceed with:
a)Celsius to Fahrenheit
b)Fahrenheit to Celsius
c)I'm done
a
Let's get started!
Please enter a celsius value.
100
the value you entered was 100
that equals 212 degrees fahrenheit
thank you for using the ULTRACONVERTOR 3000
Press any key to continue . . .
 

Goosemaster

Lifer
Apr 10, 2001
48,775
3
81
updated code:


#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
double celsius;
double fahrenheit;
char m ;
char n;

//program introduction. Asks for confirmation to continue
cout << "WELCOME TO THE ULTRACONVERTOR 3000, YOUR SOURCE FOR TEMPERATURE CONVERSION," << endl;
cout << "FUFILLING ALL YOUR TEMPERATRUE NEED SINCE 1955" << endl;
cout << "\nWOULD YOU LIKE ME TO CONVERT TEMPERATURES TODAY?" << endl;
cout << "TYPE YES OR NO TO CONTINUE" << endl;
cin >> m;

//decides whether they typed yes or no by simply checking the first letter
switch( m ) {
case 'y':
case 'Y':
cout << "\n\n\ngreat, let's get started!" << endl;
//if yes, the temp. program begins asking user for which task to proceed with


//while loop that will repeat the program until I select option c
do

{
//first case executes the celsius to fahrenheit conversion module
cout << "\n\nPlease select which type of conversion you would like to proceed with:" << endl;
cout << "a)Celsius to Fahrenheit \nb)Fahrenheit to Celsius \nc)I'm done" << endl;
cin >> n;

switch (n)
case 'a':
case 'A':
cout << "Let's get started!" << endl;
cout << "Please enter a celsius value." << endl;
cin >> celsius;

fahrenheit = ((9.0/5)*celsius) + 32;

cout << "the value you entered was " << celsius << endl;
cout << "that equals "<< fahrenheit << " degrees fahrenheit" << endl;
break;

//second case executes the fahrenheit to celsius conversion module
case 'b':
case 'B':
cout << "Let's get started!" << endl;
cout << "Please enter a fahrenheit value." << endl;
cin >> fahrenheit;

celsius = (5.0/9)*(fahrenheit - 32);

cout << "the value you entered was" << fahrenheit << endl;
cout << "that equals "<< fahrenheit << "celsius" << endl;


cout << "thank you for using the ULTRACONVERTOR 3000" << endl;
}

while ( n!= 'c');


cout << "thank you for using the ULTRACONVERTOR 3000" << endl;


//if not, the program identifies their answer as a no and the program ends
break;
case 'n':
case 'N':
cout << " too bad." << endl;
break;
default:
cout << "too bad" << endl;
break;

}



//fin
system ("PAUSE");

}
 

JetBlack69

Diamond Member
Sep 16, 2001
4,580
1
0
also, you should have switch(n) { and then a closing bracket } when you are done with the switch case statement
 

fs5

Lifer
Jun 10, 2000
11,774
1
0
the ordering of your code is messed up, why do you have a do while inside the switch statement?
 

fs5

Lifer
Jun 10, 2000
11,774
1
0
okay, now you need opening and closing brackets around the switch as jet said.

and also close your first switch, your first switch should close after the use selects yes, not execute code inside.