Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ and please Add comments thank you CAO2 computation: currencies Go through this exercise step by step. Do not try to speed up by skipping

image text in transcribed

image text in transcribedC++ and please Add comments thank you

CAO2 computation: currencies Go through this exercise step by step. Do not try to speed up by skipping steps. Test each step by entering at least three values -- more values would be better. By following each step the final result will be a powerful and useful program. In this assignment you will write two functions, using the test first principle. The first function is called to_euro( double amount, string currency), and it converts an amount of money to euros, from some other currency: US dollar, Japanese yen, UK pounds sterling, or Chinese yuan. It should take two arguments. The first argument is the amount to convert from, and the currency is the currency to convert from, into euros. The second function is called from_euro( double amount, string currency), and it converts an amount of money from euros, to some other currency: US dollar, Japanese yen, UK pounds sterling, or Chinese yuan. It should take two arguments. The first argument is the amount to convert from, and the currency is the currency to convert to, from euros. Step 1. write the tests 1. First, choose your tests. o The tests you choose should test the functions in unusual cases as well as usual ones. For example: how much money should the functions be able to handle? What about very small amounts? What about negative amounts? o For each currency: choose some amounts and write them down. Now find the euro equivalents: use Google or similar. Write them down also. 2. Write a small function called tester(), called from main(), which calls to_euro() and from_euro() once for each of your tests. 3. Write a skeleton version of each function: the least amount of code necessary to make the program compile and run, printing 1.00 EUR on screen. It will consist of 1. the correct forward declaration, 2. the calls from tester(), and 3. the correct function definition first line 4. a return statement, between curly brackets. At this stage, simply type return 1.0; Step 2. Write the function guts 4. Now write the guts of the to_euro() function. Remember: write a little, test a little ... You will have finished this step when the program runs, calling to_euro() and printing on screen the converted euro amounts you wrote down in step 1. 5. Now, in the same program, develop the from_euro() function similarly. Step 3. Write the main() loop 6. Now, in main(): Comment out the call to the tester() function you used to develop your from_euro() and to_euro() code. You won't be needing it for the moment. 7. Write a loop in main() that reads one amount and one currency each time around. So the user (a human, or another computer program) can enter amounts such as 55 dollars, 3.28 yuan, 4.50 yen. o Convert the amount into euros. o keep track of which is the smallest (euro) value and which is the largest (euro) value you have seen so far. o Each time through the loop output the value entered. If it's the smallest so far, write the smallest so far after the number. If it is the largest so far, write the largest so far after the number. 8. Gracefully reject values without currencies, or with currencies that are not handled. 9. Keep track of the sum of amounts entered (as well as the smallest and the largest) and the number of amounts entered. When the loop ends, print the smallest, the largest, the number of values, and the sum of values. Note that to keep the sum, you have to decide on a unit to use for that sum; use euros. At the end, write out the sum in all the currencies that the functions can handle. 10. Keep all the amounts entered (converted into euros) in a vector. At the end, write out those values. 11. Before writing out the amounts from the vector, sort them (that'll make them come out in increasing order)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago