Question: Write in C++, PLEASE!! Here is an example run with two currency amounts. You output does not need to match this exactly but it should

Write in C++, PLEASE!!

Write in C++, PLEASE!! Here is an example run with two currency

Here is an example run with two currency amounts. You output does not need to match this exactly but it should look similar. You can use the numbers here to check your values.

Welcome to the Currency Exchange Service. Menu ---- 1) Convert dollars to bitcoin 2) Convert bitcoin to dollars 3) Exit Enter your choice: 1 Please input the amount in USD to exchange: 2000 The final amount in BTC is: 0.22 Welcome to the Currency Exchange Service. Menu ---- 1) Convert dollars to bitcoin 2) Convert bitcoin to dollars 3) Exit Enter your choice: 2 Please input the amount in BTC to exchange: 5 The final amount in USD is: $233594.55 Welcome to the Currency Exchange Service. Menu ---- 1) Convert dollars to bitcoin 2) Convert bitcoin to dollars 3) Exit Enter your choice: 4 Invalid entry, please try again. Welcome to the Currency Exchange Service. Menu ---- 1) Convert dollars to bitcoin 2) Convert bitcoin to dollars 3) Exit Enter your choice: 3 Exiting... 

Here is the starter code:

#include

using namespace std;

//

// Starter file for Lab #6.

// Bitcoin converter.

//

// Constants here. This one is for the dollar to BTC conversion.

const double RATE_BTC = 0.00012;

//

// Here is an example function that converts dollars to bitcoin. The return

// value is a 'double' type, and the single parameter is also a 'double'. The

// return value should be the number of bitcoin equal to 'dol' dollars, with the

// service fee deducted. The other function (BTCToDollars) should look similar.

//

double dollarsToBTC(double dol) {

// Your code goes here

}

int main() {

double val = 0;

int myChoice;

// This is an infinite loop that will continuously ask the user for a value,

// call the function for conversion, then ask again until the user requests exit (option 3).

// At that point you can use 'break' to exit the loop, or, since the program is

// done at that point, use 'return 0'.

//

// Notice that 'break' also exits the switch case, but does not exit the

// loop unless you use it outside of the switch. 'break' will break out

// of the innermost loop, which is the while() loop here.

while (true) {

cout

// Add your menu here

// Accept user input

cin >> myChoice;

// This 'switch' statement examines the value of myChoice, and selects one of the

// cases below. The code will "fall through" (keep going) to the next case statement

// if it does not hit a break, so you should have a 'break' after the code for handling

// each option here. See Gaddis section 4.41 for more on the switch() statement.

switch (myChoice) {

case 1:

cout

cin >> val;

cout

break;

//

// Continue with more case statements here. Use 'default' for

// handling invalid menu entries.

//

//

} // End of the switch() statement

} // End of the while() loop

return 0;

}

that when the function is done, the 'return x' keyword is used and the value x is sent back to the caller of the function. Note that the only function we've learned so far, main(), is an int type function and it returns an int when it is finished ('return 0', usually). This lab will help you practice writing functions so you can observe their overall structure and how they are called from main(). Assignment Imagine you are writing a program for a currency exchange service that will exchange any amount in US Dollars (USD) for bitcoin (BTC). Some background on bitcoin is here e, if you're interested, but for our purposes we will treat it as a currency like any other, with its own exchange rate. Your service has to make a profit, and there is a "markup" charged to customers when doing the exchange. To complete this lab, write a program that does the following: Asks the user, in a menu, which type of conversion to do: Dollars to bitcoin Bitcoin to dollars Using one of two functions, calculates the result, subtracting the service fee Outputs the answer with two digits past the decimal precision Invalid menu entries should be detected (ask the user to input again) Repeats until the user requests an exit Exchange Rates Use these values for your currency and service charges: One US Dollar is equal to 0.000019 bitcoin One bitcoin is equal to 51,909.90 US Dollars A 10% service fee is taken from the final result. This can be done by reducing the final amount in either currency by 10%. Your Two Functions Convert the currency using these two functions in your program -- these should include the handling of the service charge in their return value. 1) dollarsToBTC which converts a given dollar amount (a double) to bitcoin and returns that amount (a double). 2) BTCtoDollars which converts a given bitcoin amount (a double) and returns that amount (a double). Output the conversion result and loop until the user selects the exit option. Note: The BTC exchange rate is small, so you may have to enter a larger number to see a result other than 0. Here is a starter file for this lab

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!