Question
LabTask week06 Write a program that prompts the user to enter the exchange rate from currency in US dollars to Chinese RMB. Prompt the user
LabTask week06 Write a program that prompts the user to enter the exchange rate from currency in US dollars to Chinese RMB. Prompt the user to enter 0 to convert from US dollars to Chinese RMB and 1 to convert from Chinese RMB to US dollars. Prompt the user to enter the amount in US dollars or Chinese RMB to convert it to Chinese RMB or US dollars, respectively. When the user enters "1" (yuans to dollars) the program should extract the dollar amount before the decimal point, and the cents after the decimal amount using the indexOf() and substring() methods.Here are the sample runs, user's input is underlined:
Enter the exchange rate from dollars to RMB: 6.81 Enter 0 to convert dollars to RMB and 1 vice versa: 0 Enter the dollar amount: 100 $100.0 is 681.0 yuan. Enter the exchange rate from dollars to RMB: 6.81 Enter 0 to convert dollars to RMB and 1 vice versa: 1 Enter the yuan amount: 1000 1000.0 yuan is $146.843 dollar 146 dollars 3 quarters 0 dimes 1 nickel 4 pennies
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started