Variable to hold multiple values - Trouble with While loop

Hello Everyone:

This is my second program after Hello World, of if my issue seems elementary, is because I just got started.

My program is supposed to ask the user to type in the exchange rate between two currencies (got that part). Second, ask the user to enter currency amounts (got that part), when the user enters 0 (sentinel value), convert each entry into the new currency, this is where I am stuck. Right now it takes all of my values adds them up and multiply by the exchange rate. I need to have each entered value print as the new rate.

I know that I need to set a variable to hold all of the unique values, I thought I did that below, but is not working as planned.

Any guidance will be greatly appreciated.

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
#include <iostream>
using namespace std;

int main()

{	
	double yen;
	double exRate;
	double yenTotal = 0;

	cout <<"Please enter todays exchange rate: ";
	cin >> exRate;

	cout <<"Please enter the yen amount or 0 to quit: ";
	cin >> yen;

	while (yen !=0){

		exRate = exRate * yen;
		yenTotal = exRate;
		

		cout << "Please enter the yen amount or 0 to quit: ";
		cin >> yen;


	}

	cout <<yenTotal <<"\n";
		
	system ("pause");
	return 0;
> I know that I need to set a variable to hold all of the unique values, I thought I did that below
¿where?
Either process the input online, or use a container (like std::vector)
Thanks, how would I process the input online?
Really? Vector? When he stated this is his first program after writing Hello World!?
1
2
3
4
5
6
7
8
9
	while (yen !=0){
		exRate = exRate * yen;
		yenTotal = exRate;
		
		cout <<yenTotal <<"\n";

		cout << "Please enter the yen amount or 0 to quit: ";
		cin >> yen;
	}


@Matri X: you are right, std::queue may be easier.
Topic archived. No new replies allowed.