In: Computer Science
Write a program in Java that first asks the user to type in today's price of one dollar in Japanese yen, then reads U.S. dollar values and converts each to yen. Use 0 as a sentinel to denote the end of dollar input. THEN the program reads a sequence of yen amounts and converts them to dollars. The second sequence is terminated by another zero value.
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
// DollarToYen.java
import java.util.Scanner;
public class DollarToYen {
public static void main(String[] args) {
// Declaring variables
double
dollarsInYen,dollars,yen;
/*
* Creating an Scanner class object
which is used to get the inputs
* entered by the user
*/
Scanner sc = new
Scanner(System.in);
//Getting the input entered by the user
System.out.print("Enter today's
prcie of one dollar in Japanese yen:");
dollarsInYen=sc.nextDouble();
// Getting the input entered by the
user
System.out.print("\nEnter no of
dollars (0 to exit):");
dollars=sc.nextDouble();
/* This while loop continues to
execute
* until the user enters a 0
*/
while(dollars!=0)
{
// Converting
dollars to yen
yen=dollars*dollarsInYen;
System.out.println("Yen :"+yen);
// Getting the
input entered by the user
System.out.print("\nEnter no of dollars (0 to exit):");
dollars=sc.nextDouble();
}
}
}
===========================================
===========================================
Output:
=====================Could you plz rate me well.Thank
You