Thursday, August 21, 2014

CurrencyConverter

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 input = new Scanner(System.in);
   
     double peso1, peso2, peso3, peso4, total;
     double USD = 43.75;
     double GBP = 78.98;
     double EUR = 56.45;
     double JPY = 0.867;
     System.out.print("Enter amount of USD: ");
     int usd = input.nextInt();
     System.out.print("Enter amount of GBP: ");
     int gbp = input.nextInt();
     System.out.print("Enter amount of EUR: ");
     int eur = input.nextInt();
     System.out.print("Enter amount of JPY: ");
     int jpy = input.nextInt();
       
     peso1 = usd * USD;
     peso2 = gbp * GBP;
     peso3 = eur * EUR;
     peso4 = jpy * JPY;
     total = peso1+peso2+peso3+peso4;
   
     System.out.println("To PHP:");
     System.out.println("USD: "+peso1);
     System.out.println("GBP: "+peso2);
     System.out.println("EUR: "+peso3);
     System.out.println("JPY: "+peso4);
     System.out.println("Total PHP: "+total);

 }
}

No comments:

Post a Comment

advertisement