Package java.util

Examples of java.util.Scanner.nextDouble()


    System.out.println("What was deposit amount for month " + months + "? ");
    deposit = keyboard.nextDouble();
    account.deposit(deposit);
   
    System.out.println("What was withdrawal amount for month " + months + "? ");
    withdrawal = keyboard.nextDouble();
    account.withdraw(withdrawal);
   
    account.earned();
    months--;
    }
View Full Code Here


        double usrIn = 0; //temp var for grades
        int pass = 0; //counter var for amount passing marks
        System.out.println("The super handy percent passing calculator!"); //intro sentence
        while (usrIn != SENTINEL) { //While the user has not tried to exit the loop, loop.
            System.out.print("Enter a grade or -1 to quit: "); //Ask user for grade or flag
            usrIn = input.nextDouble(); //Collect input
            if (usrIn > 70) { //If the number is higher than 70
                pass++; //Add one to the pass counter
            } //end if
        } //end while
        System.out.print("Number of passing grades is "+pass); //Display number of passing grades
View Full Code Here

    System.out.print("First name: ");
    fName = input.nextLine();
    System.out.print("Last name: ");
    lName = input.nextLine();
    System.out.print("Beginning balance: ");
    bal = input.nextDouble();
   
    newAcct = new Account(bal, fName, lName)//create account object
    accounts.add(newAcct);            //add account to bank accounts
   
    System.out.println("Account created. Account ID is: " + newAcct.getID());
View Full Code Here

      } else if (!action.equalsIgnoreCase("Q")) {
        System.out.print("Enter account ID: ");
        acctID = input.next();
        if (action.equalsIgnoreCase("D")) {
          System.out.print("Enter deposit amount: ");
          amt = input.nextDouble();
          easySave.transaction(1, acctID, amt);
        } else if (action.equalsIgnoreCase("W")) {
          System.out.print("Enter withdrawal amount: ");
          amt = input.nextDouble();
          easySave.transaction(2, acctID, amt);
View Full Code Here

          System.out.print("Enter deposit amount: ");
          amt = input.nextDouble();
          easySave.transaction(1, acctID, amt);
        } else if (action.equalsIgnoreCase("W")) {
          System.out.print("Enter withdrawal amount: ");
          amt = input.nextDouble();
          easySave.transaction(2, acctID, amt);
        } else if (action.equalsIgnoreCase("C")) {
          easySave.checkBalance(acctID);
        } else if (action.equalsIgnoreCase("R")) {
          easySave.deleteAccount(acctID);
View Full Code Here

        System.out.print("1. Final Amount\n2. Inital Amount\n3. Half-life (constant)\nFind: "); //Ask which equation to do
        double n, y, k, t; //Initalize intial mass, final mass, half-life and time in that order
        switch (input.nextInt()) { //Switch the input from the user
            case 1: //If user entered 1 (final mass)
                    System.out.print("Enter the inital mass: "); //Ask user for inital mass
                    n = input.nextDouble(); //Collect inital mass from user
                    System.out.print("Enter the time (years): "); //Ask user for time (years)
                    t = input.nextDouble(); //Collect time (years) from user
                    System.out.print("Enter half-life (Constant): "); //Ask user for half-life
                    k = input.nextDouble(); //Collect half-life from user
                    y = n / Math.exp((-k*t)); //Calculate final mass
View Full Code Here

        switch (input.nextInt()) { //Switch the input from the user
            case 1: //If user entered 1 (final mass)
                    System.out.print("Enter the inital mass: "); //Ask user for inital mass
                    n = input.nextDouble(); //Collect inital mass from user
                    System.out.print("Enter the time (years): "); //Ask user for time (years)
                    t = input.nextDouble(); //Collect time (years) from user
                    System.out.print("Enter half-life (Constant): "); //Ask user for half-life
                    k = input.nextDouble(); //Collect half-life from user
                    y = n / Math.exp((-k*t)); //Calculate final mass
                    System.out.print("Final Amount: " + y); //Display final mass
            break;
View Full Code Here

                    System.out.print("Enter the inital mass: "); //Ask user for inital mass
                    n = input.nextDouble(); //Collect inital mass from user
                    System.out.print("Enter the time (years): "); //Ask user for time (years)
                    t = input.nextDouble(); //Collect time (years) from user
                    System.out.print("Enter half-life (Constant): "); //Ask user for half-life
                    k = input.nextDouble(); //Collect half-life from user
                    y = n / Math.exp((-k*t)); //Calculate final mass
                    System.out.print("Final Amount: " + y); //Display final mass
            break;
            case 2: //if user entered 2 (inital mass)
                    System.out.print("Enter the final mass: "); //Ask user for final mass
View Full Code Here

                    y = n / Math.exp((-k*t)); //Calculate final mass
                    System.out.print("Final Amount: " + y); //Display final mass
            break;
            case 2: //if user entered 2 (inital mass)
                    System.out.print("Enter the final mass: "); //Ask user for final mass
                    y = input.nextDouble(); //Collect final mass
                    System.out.print("Enter the time (years): "); //Ask user for time (years)
                    t = input.nextDouble(); //Collect time (years)
                    System.out.print("Enter half-life (Constant): "); //Ask user for half-life
                    k = input.nextDouble(); //Collect half-life from user
                    n = y / Math.exp(k*t); //Calculate inital mass
View Full Code Here

            break;
            case 2: //if user entered 2 (inital mass)
                    System.out.print("Enter the final mass: "); //Ask user for final mass
                    y = input.nextDouble(); //Collect final mass
                    System.out.print("Enter the time (years): "); //Ask user for time (years)
                    t = input.nextDouble(); //Collect time (years)
                    System.out.print("Enter half-life (Constant): "); //Ask user for half-life
                    k = input.nextDouble(); //Collect half-life from user
                    n = y / Math.exp(k*t); //Calculate inital mass
                    System.out.print("Inital Amount: " + n); //Display inital mass
            break;
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.