Introduction:
Hello everyone, My name is Austin I am new to these forums, and relatively new to c++. I just started studying c++ a month ago and I have never used to before so I do apologize if I sound stupid; please forgive me, and please forgive me if I misspell or have trouble understanding I have aspergers syndrome. I did have some experience prior with mostly html, anyway I am trying to make a converter program which thus far has been loads of fun but it has a long ways to go as I want multiple things to convert i.e. weight temperature etc. So far I have successfully got this program to convert Celcius to Fahrenheit and vice versa by the users own input, but there are parts where I get fuzzy and have some problems.
Problems Currently
At the bottom you will see the code which comes off the switch.
IT works fine as the only two options that work are for the user to enter 1 or 2 and if they enter anything else it displays you entered something wrong WHICH IS COOL but that ends the program. I'd like to have it say you entered something wrong but also give the user the options to enter 1 or 2 again i.e. start back up from the top. I have considered using the goto statement but from what heard that's not a good ideaa right? What can I use?
My ultimate goal is to create an awesome converter program someday with a GUI with this which I'm not sure how to do yet and also that stores all the conversions done and puts it in a text file in the same directory that the programs in. Very confusing......any help would be awesome.
NOTE: I haven't gotten to the other variables on the switch menu yet I'm working on it but need help here sort of first.
Austin
//This Program is inteneded to convert the most frequently used measurements
//Source Code Written By Austin 2010
#include <iostream>
#include <string>
#include <sstream>
#include <new>
#include <math.h>
using namespace std;
// will start by declaring some namspaces to hold temeratures, distance, etc. etc. conversions
namespace temperature { // temperature namespace variables
double var = 1.8;
double vartwo = 32;
}
namespace fluid { //fluid namespace not done yet
int var = 4;
}
//start main
int main(int nNumberofArgs, char* pszArgs[])
{
//about to display choices for the user to use
char m; //main character variable for the main menu of the program where the user chooses what data they want to convert
cout << "Please Enter One Of The Following Choices, For The Data That You Want To Convert\n";
cout << "Enter One Of The Following Letters From" << "The Menu Below \n";
cout << "A - For Temperature\n";
cout << "B - For Fluid\n";
cout << "C - For Weight\n";
cout << endl;
cin >> m;
//Standard switch menu is used with this program using cases: the cases do what is stated above and it's corrosponding Letters
switch(m)
{
case 'a':
case 'A':
float contype; // holds the conversion type to be used
cout << "We Are Now Converting Temperatures \n";
cout << "You May Press q And Then Enter To Quit This Program\n";
cout << "Type 1 To Convert Celcius To Fahrenheit Or Type 2\n";
cout << "To Convert Fahrenheit To Celcius: ";
cin >> contype;
if (contype == 1)
{
double degrees; // holds the degrees that the user wants to input
cout << "We Are Now Going To Convert Celcius To Fahrenheit\n";
cout << "Please Enter The Number Of Degrees \n";
cout << "Celcius That you Want To Convert To Fahrenheit: ";
cin >> degrees;
cout << "Your Temperature Fahrenheit " << "Is " << ((degrees * temperature::var) + temperature::vartwo) << endl;
break;
}
else if (contype == 2)
{
double degrees; // holds the degrees that the user wants to input
cout << "We Are Now Going To Convert Fahrenheit To Celcius\n";
cout << "Please Enter The Number Of Degrees \n";
cout << "Fahrenheit That you Want To Convert To Celcius: ";
cin >> degrees;
cout << "Your Temperature Celcius " << "Is ";
cout << ((degrees - temperature::vartwo) / temperature::var) << endl;
Sorry about not using the Code tag will certainly do that next time :). Thank you so much I think that this well help me I may ask for more help; I was looking all over online for all kinds of things that weren't helpful lol.