Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a program that prompt the user to enter the exchange rate from currency in U.S dollar to chinese RMB . Prompt the user to

write a program that prompt the user to enter the exchange rate from currency in U.S dollar to chinese RMB . Prompt the user to enter 0 to convert from U.S. dollar to chinese RMB AND 1 to convert from chinese RMB and U.S dollar. Prompt the user to enter the amount in U.S dollar or chinese RMB to convert it to chinese RMB or U.S. dollar

Here is the solution but it has some errors I need to fix them . Please help:

import java.text.DecimalFormat; import java.util.Scanner;

/** * @author Srinivas Palli * */ public class USDRMBConversion {

/** * @param args */ public static void main(String[] args) { Scanner input = new Scanner(System.in); DecimalFormat df = new DecimalFormat("0.00"); System.out.print("Enter the exchange rate from dollars to RMB: "); double rate = input.nextDouble();

System.out .print(" Enter 0 to convert dollars to RMB and 1 vice versa: "); int number = input.nextInt();

if (number == 0) System.out.print(" Enter the dollar amount: "); else if (number == 1) System.out.print(" Enter the RMB amount: "); else System.out.println("Incorrect input"); double convert = input.nextDouble();

double total1 = rate * convert; double total2 = convert / rate; if (number == 0) System.out.println("$" + convert + " is " + df.format(total1) + " yuan"); else if (number == 1) System.out.println(convert + " yuan is $" + df.format(total2));

} }

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

Step: 3

blur-text-image

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

3. Did you seek anyones advice?

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago