Package java.util

Examples of java.util.Scanner.nextFloat()


        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();
View Full Code Here


        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();
        }
View Full Code Here

        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"
View Full Code Here

            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");
View Full Code Here

     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        System.out.print("Hello! This is the temperature converter.\nPlease input the temperature value (Celsius degrees): ");
        Float celsius = new Float(keyboard.nextFloat());
        System.out.println(celsius + " Celsius degrees equals to:\n" +
                new DecimalFormat("#.##").format(9/5F * celsius + 32) + " Fahrenheit degrees\n" +
                new DecimalFormat("#.##").format(celsius + 273) + " Kelvin degrees");
        //В идеале - предоставить возможность выбора конвертируемой шкалы и шкалы, в которую конвертируем.
    }
View Full Code Here

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.