Question

In: Computer Science

2. Create a C++ program that converts the number of American dollars entered by the user...

2. Create a C++ program that converts the number of American dollars entered by the user into one of the following foreign currencies: Euro, British pound, German mark, or Swiss franc. Allow the user to select the foreign currency from a menu. Store the exchange rates in a four-element double array named rates. Notice that the menu choice is always one number more than the subscript of its corresponding rate. For example, menu choice 1's rate is stored in the array element whose subscript is 0. Below is the sample run of the program.

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main()
{
//variable declaration
int choice;
double rates[] ={50, 70, 30, 40};
double amount, newCurAmount;
  
//get amount from the user
cout<<"Enter the amount: $";
cin>>amount;
  
//display menue
cout<<endl<<"1: Euro";
cout<<endl<<"2: British pound";
cout<<endl<<"3: German mark";
cout<<endl<<"4: Swiss franc";
  
cout<<endl<<endl<<"Enter your choice: ";
cin>>choice;
  
//calculate the new currency amount
if(choice == 1)
{
newCurAmount = amount * rates[0];
cout<<endl<<"The amount in Euro is: "<<newCurAmount;
}
else if(choice == 2)
{
newCurAmount = amount * rates[1];
cout<<endl<<"The amount in British pound is: "<<newCurAmount;
}
else if(choice == 3)
{
newCurAmount = amount * rates[2];
cout<<endl<<"The amount in German mark is: "<<newCurAmount;
}
else if(choice == 4)
{
newCurAmount = amount * rates[3];
cout<<endl<<"The amount in Swiss franc is: "<<newCurAmount;
}
else
{
cout<<endl<<"Invalid Input!";
}
return 0;
}

OUTPUT:


Related Solutions

Write a C++ program that finds the minimum number entered by the user .The user is...
Write a C++ program that finds the minimum number entered by the user .The user is allowed to enter negative numbers 0, or positive numbers. The program should be controlled with a loop statement. Break statements is not allowed to break from loop. After each number inputted by the user, The program will prompt user if they need to enter another number. User should enter either Y for yes or N for no. Make Sure the user enters either Y...
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream>, switch and if-else statements only and do not use string storing for the conversion in words. Thank you.** **Our class is still discussing on the basics of programming. Please focus only on the basics. Thank you.** Example outputs: Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four...
Write a program that converts the user's number into the desired unit of measurement. The user...
Write a program that converts the user's number into the desired unit of measurement. The user will pick the desired unit from a menu shown below. Ask the follow-up question (the number to convert) and do the math ONLY if the user picks a valid choice from the menu. You can see the conversions / multipliers needed for this program in the output section below. Menu/Prompt: Enter the number that corresponds to your desired unit conversion from the choices below:...
This is C++ Create a program that reads an HTML file and converts it to plain...
This is C++ Create a program that reads an HTML file and converts it to plain text. Console: HTML Converter Grocery List * Eggs * Milk * Butter Specifications: The HTML file named groceries.html contains these HTML tags: <h1>Grocery List</h1> <ul> <li>Eggs</li> <li>Milk</li> <li>Butter</li> </ul> When the program starts, it should read the contents of the file, remove the HTML tags, remove any spaces to the left of the tags, add asterisks (*) before the list items, and display the...
Conversion of numeral to roman number: Create a FLOWCHART and C++ PROGRAM that prompts the user...
Conversion of numeral to roman number: Create a FLOWCHART and C++ PROGRAM that prompts the user to enter a number (from 1-3000 only) then output the number and its corresponding roman numeral number. ***validate the input (it must be 1-3000 only) SAMPLE OUTPUT: Enter a Number: 0 Number should be from 1-3000 only (Terminated) Enter a Number: -5 Number should be from 1-3000 only (Terminated) Enter a Number: 3500 Number should be from 1-3000 only (Terminated) Enter a Number: 1994...
Time Calculator Create a C++ program that lets the user enter a number of seconds and...
Time Calculator Create a C++ program that lets the user enter a number of seconds and produces output according to the following criteria: • There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. • There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or...
Fat Percentage Calculator Create a C++ program that allows the user to enter the number of...
Fat Percentage Calculator Create a C++ program that allows the user to enter the number of calories and fat grams in a food. The application should display the percentage of the calories that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating the food is low in fat. One gram of fat has 9 calories, so: Calories from fat = fat grams *...
Use c# Create a program called ResortPrices that prompts the user to enter the number of...
Use c# Create a program called ResortPrices that prompts the user to enter the number of days for a resort stay. Then display the price per night and the total price. Nightly rates are R 500.00 for one or two nights, R 650.00 for three or four nights, R 850.00 for five, six or seven nights, and R 1500.00 for eight nights or more.
c ++ program that converts from any base to a decimal number
c ++ program that converts from any base to a decimal number
Instructions: Create a Java program that reads a string entered by the user and then determines...
Instructions: Create a Java program that reads a string entered by the user and then determines and prints how many of each lowercase vowel (a, e, i, o, and u) appear in the entire string. Have a separate counter for each vowel. Also, count and print the number of non-vowel characters. Example: User enters: "This house is beautiful." a: 1 e: 2 i: 3 o: 1 u: 2 non-vowel:10
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT