Storing transaction using vector and then recall that transaction

Is there anyone can do this for me I stuck in this assignment I'm getting more confuse doing it and I don't know what to do.

Here it is.

Requirement 1
The program MUST provide a user interface and functionality for users
to convert between Fijiian Dollars, Vanuatu Vatu and Samoan Tala.

There must be an option to convert from Fijiian Dollars to Vanuatu Vatu and
vice versa.

There must be an option to convert from Fijiian Dollars to Samoan Tala and
vice versa.

There must be an option to convert from Samoan Tala to Vanuatu Vatu and
vice versa.

Requirement 2
The program MUST provide a user interface option and functionality
to recall all the previous transactions since the start of the program.

Requirement 3 The program SHOULD start with an internal opening balance of
FJD$10,000, V10,000,000 and T1,000,000. Each transaction should increment or
decrement the internal balances. Transactions that result in an internal balance
that is less than 0 should be disallowed

Here is my coding for requirement 1 only requirement 2 and 3 that I still stuck in it
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
#include<iostream>
using namespace std;
	
int main()
{      //Declaration of varibles
    
		int Fijian=10000;
    	int Vatu=10000000;
    	int Tala= 0<=1000000;
		char choice;
       	float V,T,F;
      	const float Rate1=51.6718;
      	const float Rate2=0.0193529159;
      	const float Rate3=0.7856940821;
      	const float Rate4=1.27276;
      	const float Rate5=40.7806;
      	const float Rate6=0.0245214636;
      
    cout <<"$*****************************************************************************************$"<< endl;
	cout <<"$ Welcome this is the program to convert the currency between the three types of currency $"<< endl;
	cout <<"$                                                                                         $"<< endl;
	cout <<"$ the Fijian Dollar, the Samoan Tala and the Vanuatu Vatu to convert every one to each    $"<< endl;
	cout <<"$                                                                                         $"<< endl;
	cout <<"$ other and also to vice versa each other. This program has an internal opening balance   $"<< endl;
	cout <<"$                                                                                         $"<< endl;
	cout <<"$ of each currency which the Fijian Dollar=$10,000 and the Vanuatu Vatu=$10,000,000       $"<< endl;
	cout <<"$                                                                                         $"<< endl;
	cout <<"$ and the third one which is the Samoan Tala=$1,000,000. Each transactiion you enter      $"<< endl;
	cout <<"$                                                                                         $"<< endl;
	cout <<"$ will increment or decrement the internal balance in this program.                       $"<< endl;
	cout <<"$*****************************************************************************************$"<< endl; 
       
      system("pause");
	cout <<"-------------------------------------------------------------------------"<<endl;	   
	cout <<"Press 'a' to convert fijian dollar to vanuatu vatu or press 'b' to vice versa"<<endl;
	cin >> choice;{
	while  (choice!='a' &&choice!='b' )
		{
		cout << " Invalid choice Please press your choice again"<<endl;
		cin >>choice;
		
		}		
	

		if (choice =='a' ){
			cout <<"\nEnter how many fijian dollar you want to convert:";
			cin >> F;
			while  (cin.fail())
				{
				cin.clear();
				cin.ignore();
				
				cout << " Invalid choice Please press your choice again"<<endl;
				cin >>F;
				}
			V= F* Rate1;
			cout << F << " fijian dollar convert into vanuatu vatu is : $" << V << endl;
			
		}
		
		else if (choice=='b'){
		cout <<"\nEnter how many vanuatu vatu you want to convert:";
			cin >> V;
			F = V * Rate2;
			cout << V << " vatu convert into Fijian is equal to $" << F <<" Fijian dollar"<< endl;}
			
	
		
		}
		
		
cout <<"------------------------------------------------------------------------"<<endl;
cout <<"Press 'c' to convert samoan tala to fijian dollar or press 'd' to vice versa"<<endl;
cin >> choice;{
while  (choice!='c' && choice!='d' )
		{
		cout << " Invalid choice Please press your choice again"<<endl;
		cin >>choice;
		
		}

	
		if (choice=='c'){
			cout <<"\nEnter how many samoan tala you want to convert:"<< endl;
			cin >> T;
			F = T * Rate3;
			cout << T << " samoan tala convert into fijian dollar is  : $" << F << endl;
			
		}
		
		else if (choice=='d'){
			cout <<"\nEnter how many fijian dollar you want to convert:"<< endl;
			cin >> F;
			T = F * Rate4;
			cout << F << " fijian dollar convert into samoan tala is: $" << T << endl;}
		}
	
cout <<"------------------------------------------------------------------------"<<endl;	
cout <<"Press 'e' to convert samoan tala to vanuatu vatu or press 'f' to vice versa "<<endl;
cin >> choice;{
while  (choice!='e' &&choice!='f' )
		{
		cout << " Invalid choice Please press your choice again"<<endl;
		cin >>choice;
		
		}

		if (choice=='e'){
			cout <<"\nEnter how many samoan tala you want to convert:"<< endl;
			cin >> T;
			V = T * Rate5;
			cout << T << " samoan tala convert into vanuatu vatu is: $" << V << endl;
			}
		
		else if (choice=='f'){
		
			cout <<"\nEnter how many vanuatu vatu you want to convert:"<< endl;
			cin >> V;
			T = V * Rate6;
			cout << V << " vatu convert into samoan tala is: $" << T << endl;}
			
		}
	    
	return 0;
       
	   }

Last edited on
Hello Elshot,

Your other program http://www.cplusplus.com/forum/beginner/234841/ covered requirement 1 much better.

As it is your code now does not show options "e" of "f" until all the other options have been displayed and at least one of them chosen before you proceed to the set of choices.

Lines 19 - 31 print out a nice piece of information after the you should loose the pause and display all of the choices at one time, so the user knows what to choose from.

Now that you program is smaller it would also be a good time to shorten what you do have.

In place of all the if statements you could use a switch/case and within that when you ask the user how much to convert you could write one function that will ask for the correct input and return the amount for use.

Hope that helps,

Andy
Topic archived. No new replies allowed.