In: Computer Science
1. Currency conversion: Write a snippet that first asks the user to type
today's price for one dollar in Euros, then continues to read US dollar values
from the user and convert each to Euros until the sentinel value 0 is entered.
Format output to 2 decimal places.
*****IN JAVA********
DollarsEuros.java :
//importing package
import java.util.*;
//Java class with name DollarsEuros
public class DollarsEuros {
   // main() method
   public static void main(String[] args) {
       // Scanner class instance
       Scanner keyboard = new
Scanner(System.in);
       // this variable will store
dollars
       int dollars = 1;
       // this variable stores euros
price
       double EUROS = 0.85;
       // While loop in Java
       // This while loop will continue
till dollar is greater than 0
       while (dollars > 0) {
           // Taking
dollars as input from user
          
System.out.print("Enter today's price for one dollar : ");
           // reading
today's price for one dollar
           dollars =
keyboard.nextInt();
           //checking
dollars
          
if(dollars<=0)
           {
          
    //if dollars is less than or equal to 0
then
          
    //break while loop
          
    break;
           }
           // conversion
from dollars to euros
           double euro =
dollars * EUROS;
           // print dollars
to euros
          
System.out.println(dollars + " dollars = " + euro+" euros");
       }
}
}
=========================================
Screen showing dollars to euros conversion :
