I am learning C++ at home because my school doesn't offer C++ classes. I am extremely new to C++, so please don't mock me for simple mistakes. That aside, I am writing a program for practice that converts an amount in a currency chosen by the user and converts it to U.S. dollars. My code looks fine to me but I get the following error message when I run it:
CurrencyConverter.cpp:5:1: error: expected unqualified-id before ‘{’ token
CurrencyConverter.cpp:12:1: error: expected unqualified-id before ‘{’ token
CurrencyConverter.cpp:19:1: error: expected unqualified-id before ‘{’ token
CurrencyConverter.cpp: In function ‘int main()’:
CurrencyConverter.cpp:31:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
CurrencyConverter.cpp:31:18: error: ‘then’ was not declared in this scope
CurrencyConverter.cpp:31:23: error: expected ‘;’ before ‘Peso’
CurrencyConverter.cpp:32:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
CurrencyConverter.cpp:32:23: error: ‘then’ was not declared in this scope
CurrencyConverter.cpp:32:28: error: expected ‘;’ before ‘Dollar’
CurrencyConverter.cpp:33:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
CurrencyConverter.cpp:33:23: error: ‘then’ was not declared in this scope
CurrencyConverter.cpp:33:28: error: expected ‘;’ before ‘Euro’
CurrencyConverter.cpp:35:1: error: expected ‘;’ before ‘return’
I am normally able to fix my programs by looking at the error messages, but this time I couldn't figure out what's wrong with my code. Any help would be greatly appreciated. Here is my program:
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
|
//This program takes a currency of the user's choice and converts an amount in that currency to U.S. dollars
#include <iostream>
using namespace std;
void Peso();
{
float solve1;
solve1=choice*0.080462;
cout <<solve1" U.S. Dollars." <<endl;
}
void Dollar();
{
float solve2;
solve2=choice*0.9796;
cout <<solve2" U.S. Dollars." <<endl;
}
void Euro();
{
float solve3;
solve3=choice*1.3040;
cout <<solve3" U.S. Dollars." <<endl;
}
int main()
{
char choice;
cout <<"What currency are you converting to U.S Dollars? Enter the corresponding letter of the currency you're converting.(a,b,or c)" <<endl;
cout <<"a)Mexican Peso; b)Canadian Dollar; c)European Euro" <<endl;
cin >>choice;
if (choice=="a") then Peso();
else if (choice=="b") then Dollar();
else if (choice=="c") then Euro();
else cout <<"Not a valid choice. Please enter one of the following: a,b, or c."
return 0;
}
|
Again, I greatly appreciate any help I get.
Thanks for your time,
Austin