Help on currency converter storing transaction in vector .

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.

Below is my coding which is not really meet those requirement

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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#include <iostream>

using namespace std;

int main (){
		double Fiji;
		double Vatu;
		double Tala;
		double Fijian=10000;
		double Samoan=1000000;
		double Vanuatu=10000000;
		double F,S,V;
		double amount;
		char choiceA;
		char choice;
		const float Rate1=51.6718;
      	const float Rate2=1.27276;
      	const float Rate3=40.7806;
      	
   do{ 	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 and decrement the internal balance in this program.                      $"<< endl;
		cout <<"$*****************************************************************************************$"<< endl; 
       
      	system("pause");
      	
		 cout <<"Press 'a' to convert Fijian Dollar to Vanuatu Vatu or Press 'b' to vice versa \n"<<endl; 
			cout <<"Press 'c' to convert Fijian Dollar to Samoan Tala or Press 'd' to vice versa \n"<<endl;
			cout <<"Press 'e' to convert Samoan Tala to Vanuatu Vatu or Press 'f' to vice versa \n"<<endl;
			cin >> choice;
		
			while  (choice!='a' &&choice!='b' &&choice!='c' &&choice!='d' &&choice!='e' &&choice!='f'){
			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 >> amount;
			while (cin.fail())
				{	
				cin.clear();
				cin.ignore();
				
				cout << " Invalid choice Please press your choice again"<<endl;
				cin >>amount;
				}
				V = amount* Rate1;
			if (V>Vanuatu){
				cout <<"The amount after the convert is over the Bank internal balance .... Convert Disallowed"<<endl;}
				
			if (V<Vanuatu){
				cout << amount << " fijian dollar convert into vanuatu vatu is : $" << V << endl;
			}
			
		}
		
		else if (choice=='b'){
				cout <<"\nEnter how many vanuatu vatu you want to convert:";
				cin >> amount;
			while  (cin.fail())
				{
				cin.clear();
				cin.ignore();
				
				cout << " Invalid choice Please press your choice again"<<endl;
				cin >>amount;
				}
				F = amount / Rate1;
			if (F>Fijian){
				cout <<"The amount after the convert is over the Bank internal balance .... Convert Disallowed"<<endl;}
			if (F<Fijian){	
				cout << amount << " vatu convert into Fijian is equal to $" << F <<" Fijian dollar"<< endl;}
		}
			
			
		if (choice=='c'){
				cout <<"\nEnter how many Fijian Dollar you want to convert:"<< endl;
				cin >> amount;
			while  (cin.fail())
				{
				cin.clear();
				cin.ignore();
				
				cout << " Invalid choice Please press your choice again"<<endl;
				cin >>amount;
				}
				F = amount * Rate2;
			if (F>Fijian){
				cout <<"The amount after the convert is over the Bank internal balance .... Convert Disallowed"<<endl;}
			if (F<Fijian){
				cout << amount << " Fijian Dollar convert into Samoan Tala is  : $" << F << endl;}	
				
		}
		
		else if (choice=='d'){
				cout <<"\nEnter how many Samoan Tala you want to convert:"<< endl;
				cin >> amount;
			while  (cin.fail())
				{
				cin.clear();
				cin.ignore();
				
				cout << " Invalid choice Please press your choice again"<<endl;
				cin >>amount;
				}
				F = amount / Rate2;
			if (F>Fijian){
				cout <<"The amount after the convert is over the Bank internal balance .... Convert Disallowed"<<endl;}
			if (F<Fijian){
			cout << amount << " Samoan Tala convert into Fijian Dollar is: $" << F << endl;}
		}
		if (choice=='e'){
				cout <<"\nEnter how many samoan tala you want to convert:"<< endl;
				cin >> amount;
			while  (cin.fail())
				{
				cin.clear();
				cin.ignore();
				
				cout << " Invalid choice Please press your choice again"<<endl;
				cin >>amount;
				}
				V = amount * Rate3;
			if (V>Vanuatu){
				cout <<"The amount after the convert is over the Bank internal balance .... Convert Disallowed"<<endl;}
			if (V<Vanuatu){
				cout << amount << " 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 >> amount;
			while  (cin.fail())
				{
				cin.clear();
				cin.ignore();
				
				cout << " Invalid choice Please press your choice again"<<endl;
				cin >>amount;
				}
				S = amount / Rate3;
			if (S>Samoan){
				cout <<"The amount after the convert is over the Bank internal balance .... Convert Disallowed"<<endl;}
			if (S<Samoan){
				cout << amount << " vatu convert into samoan tala is: $" << S << endl;}
		}
		
		cout <<"Press 'y' to run the converter again or 'x' to continue"<<endl;
		cin >> choiceA;
			
			while  (choiceA!='y' &&choiceA!='x'){
			cout << " Invalid choice Please press your choice again"<<endl;
			cin >>choiceA;
			
			}
		 if (choiceA=='y')
			system("CLS");
			
   }       while(!(choiceA=='x'));
 		 {
  			if (choiceA=='x' && choice=='a'){
			  
  				Fiji = Fijian + amount;
  				Vatu = Vanuatu - V;
  				cout <<"The total balance after the convert is $"<< Fiji << " Fijian balance and $"<< Vatu << " the Vanuatu balance"<< endl;
  			}
			
  			
  			if (choiceA=='x' && choice=='b'){
			  
  				Vatu = Vanuatu + amount;
  				Fiji = Fijian - F;
  				cout <<"The total balance after the convert is $"<< Vatu << " Vanuatu  balance and $"<< Fiji << " the Fijian balance"<< endl;
  			}
  			
  			if (choiceA=='x' && choice=='c'){
			  
  				Fiji = Fijian + amount;
  				Tala = Samoan - S;
  				cout <<"The total balance after the convert is $"<< Fiji << " Fijian balance and $"<< Tala << " the Samoan balance"<< endl;
  			}
  			
  			if (choiceA=='x' && choice=='d'){
			  
  				Tala = Samoan + amount;
  				Fiji = Fijian - F;
  				cout <<"The total balance after the convert is $"<< Tala << " Samoan balance and $"<< Fiji << " the Fijian balance"<< endl;
  			}
  			
  			if (choiceA=='x' && choice=='e'){
			  
  				Tala = Samoan + amount;
  				Vatu = Vanuatu - V;
  				cout <<"The total balance after the convert is $"<< Tala << " Samoan balance and $"<< Vatu << " the Vanuatu balance"<< endl;
  			}
  			
  			if (choiceA=='x' && choice=='f'){
			  
  				Vatu = Vanuatu + amount;
  				Tala = Samoan - S;
  				cout <<"The total balance after the convert is $"<< Vatu << " Vanuatu balance and $"<< Tala << " the Samoan balance"<< endl;
  			}
  			
 		 }
  
return 0;
		}
Last edited on
Hello Elshot,

Welcome to the forum.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

Before I can comment on the program i will have to load it up in my IDE and see if it compiles first then see how it works.

Andy
Hello Elshot,

Sorry if this jumps around a bit, but my internet access was down for a short time and I did this off line as I thought of things.

As I started to check out your program I notice that the constant variables would work better above main as:

1
2
3
4
const double RATE1 = 52.13;  // <--- FJD to WST.
const double RATE1b{ 0.0192 };  // <--- WST to FJD.
const double RATE2 = 1.27276;
const double RATE3 = 40.7806;


I changed them to "double"s because the double has better precision and will store the number better. The capital letters help to remind you that the variable is defined as a constant and can not be changed. Putting this above makes it easier when a change is needed because you only have to look at one place and the change will be seen by the whole file.

I added RATE1b because just dividing by RATE1 does not give you the right answer.

In the second set of if statements the set of{}s are OK, but not needed. The math in the if statements is backwards. You have Fiji = Fijian + amount;. This should be '-' because you are deducting from the "Fiji" account and adding to the Vatu account.

A note: variable names should start with a lower case letter. I save upper case letters for classes, structs and functions.

In these second set of if statements this would be a good place to keep track of each transaction. I am thinking a struct to hold information about the transaction and then store the struct in a vector of structs.

Instead of all the if statements I would change these to a switch/case. The if statements are OK, but the switch would condense some of the code.

I have not yet gone through the whole program to see if it conforms to the instructions, but it looks close for now.

As an example I would write your prompts as : cout << "\nEnter how many vanuatu vatu you want to convert: "; notice the space after the ':' and the lack of "std::endl". This will put the "std::cin >>" on the same line as the prompt.

In the while conditions for invalid entry you should re-prompt before the "std::cin >>".

The use of "system" is not a good idea. Some people can not use this command and tends to limit you program to a Windows operating system. An alternative would be:

1
2
3
4
5
// <--- This next line may or may not be needed. It will depend on the last input statement.
//std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');  // <--- Requires header file <limits>.
// This time it is not needed.
std::cout << "\n Press Enter to continue";
std::cin.get();


My personal opinion is these next lines of the menu would work better as:
1
2
cout << "\nPress 'a' to convert Fijian Dollar to Vanuatu Vatu\n";
std::cout << "Press 'b' to convert Vanuatu Vatu to Fijian Dollar\n\n";

And the same concept for the other menu items. The other thing I would consider is taking the pause out between the opening lines and the menu. The pause is not really needed.

Hope that helps;

Hope that helps,

Andy

Edit:
Last edited on
Hello Andy

Thank you for helping me out with my problem on this coding I agree with your personal opinion which is:

1
2
cout << "\nPress 'a' to convert Fijian Dollar to Vanuatu Vatu\n";
std::cout << "Press 'b' to convert Vanuatu Vatu to Fijian Dollar\n\n";


But I still don't know how to do requirement 2 I was wrong about it, It is not about the option for the user to run again the converter it is the the option to recall the previous transaction in requirement 1.

Your first second reply is really useful to me and I hope you can help me more with my problem in this.

Elshot

Hello Elshot,

I have not really focused on that one yet, but I will work on it.

I do not think I mentioned this, but I was think of a struct to hold the transaction information and then put this in a vector (or array), I prefer the vector, that you can refer to at some other time.

I will work on it and let you know what I come up with.

For what its worth I added choice 'g' to the menu to exit the program from the menu. Also changed the following while loop and added 'g' to it. Followed by an if statement if (choice == 'g') return 0;.

When the menu has printed and after the "cin >>" I added the line:
choice = std::tolower(choice); // <--- Requires header file "<cctype>". This makes sure that "choice" is always a lower case letter.

Hope that helps,

Andy
Hello Andy,

I will work on the given idea you give and I will try to edit my program to meet the requirement in this activity.

About storing transaction in vector I still don't know how but if you can help I will work on other hint you give and hope you correct my program to meet the given requirement, I'm stuck in this, and I'm really appreciate your help.

Elshot.
Hello Elshot,

This may be a little ahead of what you know, but good to learn.

First include these header files:
1
2
3
4
#include <iostream>
#include <iomanip>  // <--- Works with "iostream" using "std::setw()" , "std::setprecision" and others.
#include <cctype>  // <--- Used for "std::tolower" and "std::toupper"
#include <vector>  // <--- For using "std::vectors" 


I put this struct in a header file, but you do not have to. Just put it above main.
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef _TRANSACTION_ 
#define _TRANSACTION_

struct Transaction
{
	std::string s_from;
	std::string s_to;
	double s_fromAmount{};
	double s_toAmount{};
};

#endif // end !_TRANSACTION_ 

The first two and last lines are for the header file do not use if you put the struct in main.

While working with choice "a" I realized that this if statement should look like this:
1
2
3
4
5
6
7
if (amount >= Fijian)
	cout << "The amount to be converted is over the Bank internal balance .... Convert Disallowed" << endl;
else
{
	cout << amount << " Fijian Dollar convert into Vanuatu Vatu is : $" << V << endl;
	SetVector(sTransaction, vTransaction, "Fijian Dollar", "Vanuatu Vatu", amount, V);
}

The if statement only has one line of code, so the {}s are not needed. Since the choice is to convert Fijian Dollars the if statement will need to know if the Fijian account has enough to cover the value of "amount". Should the if condition be false you just need the else block not an in statement checking the opposite.

After I wrote the code for the else block I decided to put this into a function. The function will have to change what is in "" for the different transactions. "amount" is the same for all and "V" will need to change for the other menu choices.

I did the function this way:
1
2
3
4
5
6
7
8
9
10
11
void SetVector(struct Transaction sTransaction, std::vector<Transaction>& vTransaction, std::string from, std::string to, double fAmt, double tAmt)
{
	sTransaction.s_from = from;
	sTransaction.s_to = to;
	sTransaction.s_fromAmount = fAmt;
	sTransaction.s_toAmount = tAmt;

	vTransaction.emplace_back(sTransaction);

	std::cout << std::endl;
}

Do not forget to put the prototype for the function above main.

Above the do/while loop I added these:
1
2
std::vector<Transaction> vTransaction;
Transaction sTransaction;


A tricky way to use the name "transaction" more than once. The "v" in "vTransaction" means vector and the "s" means struct. I hope it is not to confusing.

So far I have only worked with choice "a", so the others still need changed.

It may not be perfect, but I did some research on the exchange rates and came up with this:
1
2
3
4
5
6
const double RATE1 = 52.13;     // <--- FJD -> VUV.
const double RATE1b{ 0.0192 };  // <--- VUV -> FJD.
const double RATE2 = 1.25;      // <--- FJD -> WST.
const double RATE2b{ 0.08 };    // <--- WST -> FJD.
const double RATE3 = 41.77;     // <--- WST -> VUV.
const double RATE3b{0.0239};    // <--- VUV -> WST. 

Hope that helps,

Andy
Hello Andy,

I tried my best to edit my program with your given idea so, I work with your idea to try to correct my program so it can meet the given requirement, I work on your code above but it very difficult for me to follow I'm sorry to say this but in my class it not very clear about using vector. It an online course I take and our tutor is not clearly give detail on using vector so If you can put all your coding as 1 program so I can take it as an example and I hope it will help me more.

Elshot,

@Elshot, do you know about functions?
Do you know about switch?
Do you know about arrays?
Have you ever seen an ANSI char table? Do you know chars are stored as numbers?

It seems your teacher expects you to know about what's above, that could make your code shorter, simpler and easier to read.
Hello Enoizat,

I know a little bit about function but I don't know how to use it in my program,
And about the switch I also read a note about it but I'm not comfortable in using it and about the array I work hard reading note about it but all example are not familiar with the case in my program.

And you are right about my teacher he need our program to be shorter but I still can't write my program with fucntion switch, but my teacher prefer vector instead of array I don't what the different between both.

I hope you can help me with my coding.

Elshot.
Hello Elshot,

I did not believe that what I had said was that hard to understand. If you get stuck or confused just ask.

Once you learn the concepts of writing a program it will become easier.

Based on the other message http://www.cplusplus.com/forum/beginner/234966/
it might be best to start from the beginning. Keep the code from both because you can use parts of both.

A little help to get you started. The if statements at the beginning of the "cout" statements and just after are because I am a little picky when it comes to the display on the screen. This is as close to having a function that will clear the screen. This may not work for every screen.

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
#include<iostream>
#include <iomanip>  // <--- For std::setprecision(2).
#include <string>
#include <cctype>   // <--- std::tolower() and std::toupper() + others.
#include <limits>
#include <chrono>
#include <thread>

//using namespace std;

constexpr double RATE1{ 52.13 };    // <--- FJD -> VUV.
constexpr double RATE2{ 0.0192 };   // <--- VUV -> FJD.
constexpr double RATE3{ 1.25 };     // <--- FJD -> WST.
constexpr double RATE4{ 0.08 };     // <--- WST -> FJD.
constexpr double RATE5{ 41.77 };    // <--- WST -> VUV.
constexpr double RATE6{ 0.0239 };   // <--- VUV -> WST.

constexpr std::size_t MAXSLEEP{ 5 };// <--- Length of pause time. See line 86.

//************ Function Prototypes ************//
double GetInput(const std::string from, const std::string to, const double bal);

int main()
{      //Declaration of varibles

	double fijianBal{ 10000 };
	double vatuBal{ 10000000 };
	double talaBal{ 1000000 };
	char choice{};  //  <--- Always initialize variables when defined.
	double V{}, T{}, F{};
	bool cont{ true }, start{ true };

	do
	{
		std::cout << "$*****************************************************************************************$" << std::endl;
		if(!start)
			std::cout << "$                                                                                         $" << std::endl;
		std::cout << "$ Welcome this is the program to convert the currency between the three types of currency $" << std::endl;
		std::cout << "$                                                                                         $" << std::endl;
		std::cout << "$ the Fijian Dollar, the Samoan Tala and the Vanuatu Vatu to convert every one to each    $" << std::endl;
		std::cout << "$                                                                                         $" << std::endl;
		std::cout << "$ other and also to vice versa each other. This program has an internal opening balance   $" << std::endl;
		std::cout << "$                                                                                         $" << std::endl;
		std::cout << "$ of each currency which the Fijian Dollar=$10,000 and the Vanuatu Vatu=$10,000,000       $" << std::endl;
		std::cout << "$                                                                                         $" << std::endl;
		std::cout << "$ and the third one which is the Samoan Tala=$1,000,000. Each transactiion you enter      $" << std::endl;
		std::cout << "$                                                                                         $" << std::endl;
		std::cout << "$ will increment or decrement the internal balance in this program.                       $" << std::endl;

		if (start)
		{
			std::cout << "$*****************************************************************************************$" << std::endl;
			start = false;
		}
		else
		{
			std::cout << "$                                                                                         $" << std::endl;
			std::cout << "$*****************************************************************************************$" << std::endl;
			std::cout << "\n";
		}

		std::cout << "\n Press 'a' to convert Fijian Dollar to Vanuatu Vatu\n";
		std::cout << " Press 'b' to convert Vanuatu Vatu to Fijian Dollar\n\n";
		std::cout << " Press 'c' to convert Fijian Dollar to Samoan Tala.\n";
		std::cout << " Press 'd' to Samoan Tala to Fijian Dollar\n" << std::endl;
		std::cout << " Press 'e' to convert Samoan Tala to Vanuatu Vatu\n";
		std::cout << " Press 'f' to convertVanuatu Vatu to Samoan Tala\n\n";
		std::cout << " Press 'g' to exit\n Enter choice : ";
		std::cin >> choice;
		choice = std::tolower(choice);

		while (choice < 'a' || choice > 'g')
		{
			std::cout << " Invalid choice Please press your choice again";
			std::cin >> choice;
		}

		std::cout << std::fixed << std::showpoint << std::setprecision(2);

		switch (choice)
		{
		case 'a':
			F = GetInput("Fijian Dollars", "Vanautu Vatu", fijianBal);

			V = F * RATE1;
			std::cout << "\n " << F << " Fijian Dollar converted into Vanuatu Vatu is : $" << V << std::endl;
			std::this_thread::sleep_for(std::chrono::seconds(MAXSLEEP));  // Requires header files "chrono" and "thread"
			break;
		case 'b':
			V = GetInput("Vanuatu Vatu", "Fijian Dollar", vatuBal);

			F = V * RATE2;

			std::cout << "\n " << V << " Vanuatu Vatu converted into Fijian Dollar is equal to $" << F << std::endl;
			std::this_thread::sleep_for(std::chrono::seconds(MAXSLEEP));  // Requires header files "chrono" and "thread"
			break;
		case 'g':
			cont = false;
			break;
		default:
			break;

		}  //  End switch.
	} while (cont);

	return 0;
}

double GetInput(const std::string from, const std::string to, const double bal)
{
	double amount{};

	do
	{
		std::cout << "\n Convert " << from << " with a balance of " << bal << " to " << to << ". Enter amount: ";
		std::cin >> amount;

		while (!std::cin)
		{
			std::cin.clear();
			std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');  // <--- Requires heder file <limits>.

			std::cout << " Invalid choice Please press your choice again: ";
			std::cin >> amount;
		}

		if (amount > bal)
		{
			std::cout << "\n Your amount " << amount << " to convert exceeds the balance of " << bal;
			std::cout << "\n Please enter a smaller amount.\n";
		}
		else
			return amount;

	} while (true);
}

For now this just works with "a" and "b", but it will give you an idea of what you can do.

This is just one small step of the program. From here you can add to the switch/case for the rest of the menu and more to cover the rest of the program.

As you can see in the code the function "GetInput" not only is a function that can be used for every choice it also checks to see if a transaction can be done.

Hope that helps,

Andy
Hello Andy,

Thanks for your helping me with my problem in this coding, I try to work with your given example and it can't compile I don't know what wrong with it but some of the header file is new to me I never seen those header file before maybe later now I know I'm in a low level with my coding.

Thank you and I try to work with your given coding I hope it will help through out doing my assignment.

Elshot.
Hello Elshot,

Do not worry about some of the header files like <limits>, <chrono> and <thread> although the <limits> header file is worth taking a look at and do not worry if you do not understand what you are seeing. This page can give you an idea of what the <limits> header file has: http://www.cplusplus.com/reference/limits/numeric_limits/

One of the nice things about C++ is that you do not have to understand everything about header files or their functions at first only how to use it. The understand will come later.

The code I offered is just a better way coding something that is more likely to be cross platform that more people can use.

If you are having problems with you new code post it so I can check it out. Struggling to figure out what is wrong is worth the time to learn something, but at some point you have to accept that you are spending to much time trying to make it work.

Hope that helps,

Andy
Hello Andy,

Thank you for helping me with all of this on my assignment there is a new code I'm working on it now hope you can help to start off with it,

Elshot
Hello Elshot,

Post it under a new topic when you have questions and I will look for it.

Andy
Hello Andy,

Thank you for your help and my new assignment is about reading from a file I will work on it till I stuck then I will post it with my question.

Elshot
Topic archived. No new replies allowed.