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: