Question: /** A simple currency converter. It multiplies a given rate by a given amount to get a converted amount. */ // use class CurrencyConverter for

/** A simple currency converter. It multiplies a given rate by a given amount to get a converted amount. */ // use class CurrencyConverter for the CurrencyConverterTester public class CurrencyConverter { //instance variables private double rate ; //conversion rate /** Constructor method: initialize rate with a given rate (aRate) @param rate the conversion rate */ public CurrencyConverter(double aRate) { rate = aRate; } /** Converts given amount according to rate. @param amount the amount to convert @return the product of rate and amount */ public double convert(double amount) { return rate * amount; } } /** Converts money using CurrencyConverter */ import java.util.* ; public class CurrencyConverterTester { public static void main(String[] args) { //Normally the scanner is based on System.in, //Scanner scanner = new Scanner(System.in) ; //but for predictability we set the input to a fixed sequence: Scanner scanner = new Scanner("0.79447 100 20 88.88 q") ; System.out.print("Conversion factor (euros per dollar): ") ; //We could use scanner.nextDouble() here, but this is an example //of using parseDouble, which you need in the next loop. String input = scanner.next() ; double rate = Double.parseDouble(input) ; System.out.println(rate) ; //-----------Start below here. To do: approximate lines of code = 1  // 1. make the CurrencyConverter object based on the rate //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. System.out.print("Dollar value (Q to quit): ") ; input = scanner.next() ; System.out.println(input) ; //echo the input  //-----------Start below here. To do: approximate lines of code = 7 // 1. write a while loop where the condition is that input is not "Q" or "q" ;   //2. use parseDouble to get the dollars amount ;   //3. use the converter object to convert the dollars to euros ;   //4. print the dollars and euros in the style shown in the Expected region (Hint: use printf);   //5. prompt for the next input: Dollar value (Q to quit):  //6. read the next input ;   //7. echo the input (i.e., print it out) //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. System.out.println("Expected:") ; System.out.println( "Conversion factor (euros per dollar): " + "0.79447 " + "Dollar value (Q to quit): " + "100 " + "100.00 dollars = 79.45 euros. " + "Dollar value (Q to quit): " + "20 " + "20.00 dollars = 15.89 euros. " + "Dollar value (Q to quit): " + "88.88 " + "88.88 dollars = 70.61 euros. " + "Dollar value (Q to quit): " + "q" ) ; } } 

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!