Lunes, Agosto 19, 2013

LabExer#2

2. Class Name: CurrencyConverter. The four major currencies USD (US Dollar), GBP (Great British Pound), EUR (Euro), and JPY (Japanese Yen) has its following exchange rates against a peso respectively: USD=43.75, GBP=78.98, EUR=56.45, and JPY=0.867. Develop a program that will compute how much will it costs in peso for every given currency. Calculate and display the total amount. (Ask 4 inputs for each of the currency, afterwards, display its equivalent peso exchange rate.



import java.util.Scanner;

public class CurrencyConverter {

    public static void main(String[] args) {
        Scanner amante=new Scanner(System.in);
       
        double USD=43.75,GBP=78.98,EUR=56.45,JPY=0.867;
       
        System.out.println("Enter USD: ");
        double input=amante.nextDouble();   
        System.out.println("Enter GBP: ");
        double input1=amante.nextDouble();   
        System.out.println("Enter EUR: ");
        double input2=amante.nextDouble();   
        System.out.println("Enter JPY: ");
        double input3=amante.nextDouble();   
       
        System.out.println("USD to Peso: " +(input*USD)+ "\nGBP to Peso: " +(input*GBP)+ "\nEUR to Peso: " +(input*EUR)+ "\nJPY to Peso: "+(input*JPY));
    }
}

Walang komento:

Mag-post ng isang Komento