Ambiguous Error

I have a simple code but a lot of the couts say they are ambiguous. Any help is appreciated, I don't know what is causing this. I am running this on Microsoft Visual Studio 2013.

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
 #include <iostream>

using namespace std;
int main()
{
	//declaring variables
	double  usDollar = 1;
	double	canDollar = .9813;
	double	euro = .757;
	double  indRup = 52.53;
	double	japYen = 80.92;
	double	mexPeso = 13.1544;
	double	britPound = .6178;

	int option;
	char currency;
	double userInput;

	system("color 81");

	do 
	{
		cout << "1. Convert your currency to US Dollars." << endl;
		cout << "2. Convert US Dollars to other currency.\n" << endl;

		while ((cout << "Please enter the number of the task you would like to perform: \n")) && !((cin >> option))
		{
			cout << "Thats not a number\n\n";
			cin.clear();
			cin.ignore(numeric_limits<streamsize>::max(), '\n');
		}

		if (option == 1)
		{

			cout << "(C) = Canadian Dollar" << endl;
			cout << "(E) = Euro " << endl;
			cout << "(I) = Indian Rupee" << endl;
			cout << "(J) = Japanese Yen" << endl;
			cout << "(M) = Mexican Peso" << endl;
			cout << "(B) = British Pound" << endl;

			cout << "\nPlease type the letter that corresponds with the currency you \nwant to exchange:" << "\n";
			cin >> currency;

			switch (toupper(currency))
			{
			case 'C':
				cout << "Please ener the amount of Canadian Dollars you would like to exchange:" << endl;
				cin >> userInput;
				cout << "\nYou now have " << userInput / canDollar << " US Dollars." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'E':
				cout << "Please enter the amount of Euros you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput / euro << " US Dollars." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'I':
				cout << "Please enter the amount of Indian Rupees you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput / indRup << " US Dollars." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'J':
				cout << "Please enter the amount of Japanese Yen you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput / japYen << " US Dollars." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'M':
				cout << "Please enter the amount of Mexican Pesos you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput / mexPeso << " US Dollars." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'B':
				cout << "Please enter the amount of British Pounds you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput / britPound << " US Dollars." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			default: system("color 4f");
				cout << "\nInvalid Data" << endl;
				system("color 81");
			}
		}

		if (option == 2)
		{
			cout << "(C) = Canadian Dollar" << endl;
			cout << "(E) = Euro " << endl;
			cout << "(I) = Indian Rupee" << endl;
			cout << "(J) = Japanese Yen" << endl;
			cout << "(M) = Mexican Peso" << endl;
			cout << "(B) = British Pound" << endl;

			cout << "\n\nPlease type the letter that corresponds with the currency you wish to \nexchange to:" << endl;
			cin >> currency;

			switch (toupper(currency))
			{
			case 'C':
				cout << "Please ener the amount of U.S. Dollars you would like to exchange:" << endl;
				cin >> userInput;
				cout << "You now have " << userInput * canDollar << " Canadian Dollars." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'E': cout << "Please enter the amount of U.S. Dollars you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput * euro << " Euros." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'I': cout << "Please enter the amount of U.S. Dollars you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput * indRup << " Indian Rupees." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'J': cout << "Please enter the amount of U.S. Dollars you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput * japYen << " Japanese Yen." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'M': cout << "Please enter the amount of U.S. Dollars you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput * mexPeso << " Mexican Pesos." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			case 'B': cout << "Please enter the amount of U.S. Dollars you would like to exchange: " << endl;
				cin >> userInput;
				cout << "You now have " << userInput * britPound << " British Pounds." << endl;
				cout << "--------------------------------------------------------------" << endl;
				break;
			default: system("color 4f");
				cout << "\nInvalid Data" << endl;
				system("color 81");
			}
		}

		else if (option < 1 || option > 2)
		{
			cout << "Invalid data " << endl;
			cout << "------------------------------------------------------------------" << endl;
		}
	} while (option < 1 || option > 2);

	system("pause");
	return 0;
}
Last edited on
I'm using mingw and was able to compile this after adding #include <limits> and changing line 26 to:
1
2
while ((cout << "Please enter the number of the task you would like to perform: \n")
               && !(cin >> option)) {
That worked for me as well! thank you so much!!
Topic archived. No new replies allowed.