The following program takes in American money and converts it intoforeign curren
ID: 3615127 • Letter: T
Question
The following program takes in American money and converts it intoforeign currency. Run thisprogram and observe the results. You can input anything forthe dollars to be converted. Notice
that it has dummy methods (stubs) that always return 0. Complete the program by turning all
the stubs into workable methods. Make sure that methodsreturn the converted dollars into the
proper currency. Although the exchange rate may vary from dayto day, use the following
conversion chart for the program. These values should bedefined as constants in the global
section so that any change in the exchange rate can be made thereand nowhere else in the
program. Make sure to carefully check that your output iscorrect.
One dollar = 1.06 euros
= 9.73 pesos
= 124.35 yen
// This program will input American money and convert it to foreigncurrency
public class Lab9_Ex3
{
public static void main (String [] args)
{
double dollars;
double euros;
double pesos;
double yen;
Scanner input = new Scanner(System.in);
// Fill in the code to outputthe value of dollars converted
// to euros, pesos and yen
System.out.println("Please input the amount of American Dollars you“
+ “ want converted");
System.out.print("to yen: “;
dollars = input.nextDouble();
//Fill in the code to output the value of those dollars convertedto
//yen
System.out.println("Please input the amount of American Dollarsyou” +
“ want converted ");
System.out.print(" to euros: ");
dollars = input.nextDouble();
// Fill in the code to output the value of thosedollars converted
// to euros
System.out.println("Please input the amount of American Dollars you“
+ “want converted)";
System.out.print(" to pesos: ");
dollars = input.nextDouble();
// Fill in the code to output the value of thosedollars converted
// to pesos
System.exit(0);
}
// All of the methods are stubs that just serve to test themethods
// Replace with code that will cause the methods to executeproperly
// ************************************************************************
// convertToYen
//
// task: Thismethod takes a dollar value and converts it to yen
// data in: dollars
// data returned: yen
//
// ***********************************************************************
public static double convertToYen(double dollars)
{
// Replace with code that will cause the methodsto execute properly
return 0; }
// ************************************************************************
// convertToEuros
//
// task: Thismethod takes a dollar value and converts it to euros
// data in: dollars
// data returned: euros
//
// ***********************************************************************
public static double convertToEuros(double dollars)
{
// Replace with code that will cause the methodsto execute properly
return 0;
}
// ************************************************************************
// convertToPesos
//
// task: This methodtakes a dollar value and converts it topesos
// data in: dollars
// data returned: pesos
//
// ***********************************************************************
public static double convertToPesos(double dollars)
{
// Replace with code that will cause the methodsto execute properly
return 0;
}
}
Explanation / Answer
please rate - thanks // This program will input American money and convert it to foreigncurrency import java.util.*; public class Lab9_Ex3 { public static final double euro=1.06; public static final double peso=9.73; public static final double yens=124.35; public static void main (String [] args) { double dollars; double euros; double pesos; double yen; Scanner input = new Scanner(System.in); // Fill in the code to outputthe value of dollars converted // to euros, pesos and yen System.out.println("Please input the amount of American Dollars you" + " want converted"); System.out.print("to yen: "); dollars = input.nextDouble(); //Fill in the code to output the value of those dollars convertedto //yen yen=convertToYen(dollars); System.out.println("$"+dollars+" = "+yen+"yen"); System.out.println("Please input the amount of American Dollarsyou" + " want converted "); System.out.print(" to euros: "); dollars = input.nextDouble(); // Fill in the code to output the value of thosedollars converted // to euros euros=convertToEuros(dollars); System.out.println("$"+dollars+" = "+euros+"euros"); System.out.println("Please input the amount of American Dollars you" + "want converted"); System.out.print(" to pesos: "); dollars = input.nextDouble(); // Fill in the code to output the value of thosedollars converted // to pesos pesos=convertToPesos(dollars); System.out.println("$"+dollars+" = "+pesos+"pesos"); System.exit(0); } // All of the methods are stubs that just serve to test themethods // Replace with code that will cause the methods to executeproperly // ************************************************************************ // convertToYen // // task: Thismethod takes a dollar value and converts it to yen // data in: dollars // data returned: yen // // *********************************************************************** public static double convertToYen(double dollars) { // Replace with code that will cause the methodsto execute properly double val=yens*dollars; return val; } // ************************************************************************ // convertToEuros // // task: Thismethod takes a dollar value and converts it to euros // data in: dollars // data returned: euros // // *********************************************************************** public static double convertToEuros(double dollars) { // Replace with code that will cause the methodsto execute properly double val=euro*dollars; return val; } // ************************************************************************ // convertToPesos // // task: This methodtakes a dollar value and converts it topesos // data in: dollars // data returned: pesos // // *********************************************************************** public static double convertToPesos(double dollars) { // Replace with code that will cause the methodsto execute properly double val=peso*dollars; return val; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.