Package currencyconverter

Source Code of currencyconverter.Main

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package currencyconverter;

import java.text.DecimalFormat;
import java.util.Scanner;


/**
*
* @author nikolajsobolev
*/
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner keyboard = new Scanner (System.in);
        Float DollarRate = new Float (8.2);
        Float EuroRate = new Float (11.15);
        Float RubleRate = new Float (0.25);
        System.out.print("Hello! This is the currency converter.\nInput the amount of hryvnas to be converted: ");
        Float UAH = new Float(keyboard.nextFloat());
        String OverwriteTrigger = new String("y");
        System.out.print("Do you want to overwrite current exchange rates? (y/n) ");
        if (OverwriteTrigger.equals(keyboard.next())){
            System.out.print("Input new dollar rate: ");
            DollarRate = keyboard.nextFloat();
            System.out.print("Input new euro rate: ");
            EuroRate = keyboard.nextFloat();
            System.out.print("Input new ruble rate: ");
            RubleRate = keyboard.nextFloat();
        }
        System.out.println(UAH + " hryvnas equals to:\n"
                + new DecimalFormat("#.##").format(UAH / DollarRate) + " dollars\n"
                + new DecimalFormat("#.##").format(UAH / EuroRate) + " euros\n"
                + new DecimalFormat("#.##").format(UAH / RubleRate) + " rubles");
        //В идеале - предоставить возможность выбора конвертируемой валюты и валюты, в которую конвертируем.
    }
}
TOP

Related Classes of currencyconverter.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.