#include <iostream>
#ifdef WIN32
#include <windows.h>
#endif
#include "console.h"
#include "clearscreen.h"
namespace con = JadedHoboConsole;
int main()
{
using std::cout;
using std::endl;
using std::cin;
char choice;
int option;
cout << "\t\t\t\t\tMenu";
cout << "\n1. Currency Converter";
cout << "\n\n2. Message 2";
cout << "\n\n3. Message 3";
cout << "\n\nPlease choose one of the options above.";
cin >> option;
switch (option)
{
case 1:
do
{
int currency;
float eurosdollars, dollarseuros, dollarsyen, yendollars, dollarsUKpounds;
float UKpoundsdollars, dollarkronor, kronordollar, dollarrubles, rublesdollar;
cout << con::fg_white <<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
<< con::fg_cyan <<"1. Dollars to Euros\t\t\t2. Euros to Dollars\n"
<< con::fg_green <<"\n3. Dollars to Yen\t\t\t4. Yen to Dollars\n"
<< con::fg_red <<"\n5. Dollars to UK Pounds\t\t\t6. UK Pounds to Dollars\n"
<< con::fg_white <<"\n7. Dollars to Sweden Kronor\t\t8. Sweden Kronor to Dollars\n"
<< con::fg_magenta <<"\n9. Dollars to Russian Rubles\t\t10. Russian Rubles to Dollars\n"
<< con::fg_white <<"\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << con::fg_yellow <<"\nPlease enter the number of the currency you want to convert: ";
cin >> currency;
if (currency == 1)
{
cout << con::fg_blue <<"\nPlease enter the amount of United States Dollars you would like to convert to European Euros: ";
cin >> eurosdollars;
cout << con::fg_blue <<"\nYou have entered " << eurosdollars << " Dollars which is equal to " << eurosdollars*0.678518116 << " Euros." << endl;
}
elseif (currency == 2)
{
cout << con::fg_blue <<"\nPlease enter the amount of European Euros you would like convert to United States Dollars: ";
cin >> dollarseuros;
cout << con::fg_blue <<"\nYou have entered " << dollarseuros << " Euros which is equal to " << dollarseuros*1.4738 << " Dollars." << endl;
}
elseif (currency == 3)
{
cout << con::fg_green <<"\nPlease enter the amount of United States Dollars you would like to convert to Japanese Yen: ";
cin >> dollarsyen;
cout << con::fg_green <<"\nYou have entered " << dollarsyen << " Dollars which is equal to " << dollarsyen*95.71255 << " Yen." << endl;
}
elseif (currency == 4)
{
cout << con::fg_green <<"\nPlease enter the amount of Japanese Yen you would like to convert to United States Dollars: ";
cin >> yendollars;
cout << con::fg_green <<"\nYou have entered " << yendollars << " Yen which is equal to " << yendollars*0.0105652 << " Dollars." << endl;
}
elseif (currency == 5)
{
cout << con::fg_red<<"\nPlease enter the amount of United States Dollars you would like to convert to United Kingdom Pounds: ";
cin >> dollarsUKpounds;
cout << con::fg_red<<"\nYou have entered " << dollarsUKpounds << " Dollars which is equal to " << dollarsUKpounds*0.598787 << " United Kingdom Pounds." << endl;
}
elseif (currency == 6)
{
cout << con::fg_red<<"\nPlease enter the United Kingdom Pounds you would like to covert to United States Dollars: ";
cin >> UKpoundsdollars;
cout << con::fg_red<<"\nYou have entered " << UKpoundsdollars << " United Kingdom Pounds which is equal to " << UKpoundsdollars*1.67004 << " Dollars." << endl;
}
elseif (currency == 7)
{
cout << con::fg_white<<"\nPlease enter the amount of United States Dollars you would like to convert to Sweden Kronor: ";
cin >> dollarkronor;
cout << con::fg_white<<"\nYou have entered " << dollarkronor << " Dollars which is equal to " << dollarkronor*7.19434 << " Sweden Kronor." << endl;
}
elseif (currency == 8)
{
cout << con::fg_white <<"\nPlease enter the amount of Sweden Kronor you would like to convert to United States Dollars: ";
cin >> kronordollar;
cout << con::fg_white <<"\nYou have entered " << kronordollar << " Kronor which is equal to " << kronordollar*0.138998 << " United States Dollars." << endl;
}
elseif (currency == 9)
{
cout << con::fg_magenta <<"\nPlease enter the amount of United States Dollars you would like to convert to Russian Rubles: ";
cin >> dollarrubles;
cout << con::fg_magenta <<"\nYou have entered " << dollarrubles << " Dollars which is equal to " << dollarrubles*31.5650 << " Russian Rubles." << endl;
}
elseif (currency == 10)
{
cout << con::fg_magenta <<"\nPlease enter the amount of Russian Rubles you would like to convert to United States Dollars: ";
cin >> rublesdollar;
cout << con::fg_magenta <<"\nYou have entered " << rublesdollar << " Rubles which is equal to " << rublesdollar*0.0316807 << " United States Dollar." << endl;
}
cout << "\nDo you want to convert again? (Y/N) ";
cin >> choice;
} while(choice != 'n' && choice != 'N');
cout << con::clr <<"\n\n\n\n\t\t\t\tGoodbye!\n";
int seconds = 1;
#ifdef WIN32
Sleep(seconds*2000);
#else
sleep(seconds);
#endif
return 0;
}
case 2:
cout << "Hello";
return 0;
break;
case 3:
cout << "o hai";
return 0;
break;
}
I'm getting an error saying that case 2 and 3 are not in a switch statement. How can I fix this guys?
The bracket in line 125 corresponds to the bracket for the entire switch statement. Delete this bracket, and then add a break; there instead and you should be ok.
EDIT: Technically you don't need to add the break; because you're ending main() right there anyway... You might consider putting the return 0; outside of the switch statement though, because it is consistent with every case. If you do this, then the break;s are necessary.
EDIT2: Oh! you also need to add another bracket (to make up for the one you deleted) to end the switch statement. You should do this at line 134, and end main() at 135.