• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

TO: C++

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Originally posted by: WobbleWobble
Originally posted by: Goosemaster
Originally posted by: WobbleWobble
Originally posted by: Goosemaster
I am not familar with getch🙁

<--nooB

I'm assuming you're starting a basic programming class. Just stick with cin or else your teacher might question the usage of getch() (like you're getting help from external sources 😛)

#include <conio.h>
...
char m;
m = getch();

thanks

this proggy..she is going to be a bute😀

getch() works differently in Visual C++, if I remember correctly

I am doing straigh c++ in dev-c++
 
When I remove the brackets it will compile but whne I run the app it give me this

Please enter a celsius value.
the value you entered was4.24399e-314
that equals 32degrees fahrenheit
Press any key to continue . . .

It pull it out of no where🙁
 
Wait till you start playing with pointers 😀

I think I will kill myself the next time I see another segmentation fault.
 
Originally posted by: screw3d
Wait till you start playing with pointers 😀

I think I will kill myself the next time I see another segmentation fault.

🙁


have any ideas why my program doesn't recognize that last 'cin' ?
 
Originally posted by: Goosemaster
OMG thank you 😀


it was so simple...😛


Not homework actually....just something I am trying to do for extra credit of sorts

If you want to make it so you don't have to press Enter, instead of doing:
cin >> m;
you can do:
m = getch();

this will make it so that Enter is not necessary.
 
Originally posted by: Legendary
Originally posted by: Goosemaster
OMG thank you 😀


it was so simple...😛


Not homework actually....just something I am trying to do for extra credit of sorts

If you want to make it so you don't have to press Enter, instead of doing:
cin >> m;
you can do:
m = getch();

this will make it so that Enter is not necessary.

I don't want to use it since we don't know it😱


 
So far I got it all working but alas, I wantt more. I am trying to create a while loop.

here is what I posted in ot:

#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 loop which I just added
 
Back
Top