Package java.util

Examples of java.util.Scanner.nextDouble()


                    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;
            case 3:
                    System.out.print("Enter the inital mass: "); //Ask user for inital mass
View Full Code Here


                    n = y / Math.exp(k*t); //Calculate inital mass
                    System.out.print("Inital Amount: " + n); //Display inital mass
            break;
            case 3:
                    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 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)
                    k = Math.log(y / n) / t;
View Full Code Here

            break;
            case 3:
                    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 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)
                    k = Math.log(y / n) / t;
                    System.out.print("Constant Half-life: " + k); //Display half-life
            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 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)
                    k = Math.log(y / n) / t;
                    System.out.print("Constant Half-life: " + k); //Display half-life
            break;
            default: System.out.print("Really?"); break; //Easter egg if you enter a number not on the menu
        }
View Full Code Here

        final double PI = 3.1415926535; //set const PI to 3.1415926535
        double radius; //variable for radius of circle (data from User)
        double circum; //variable for circumference of circle (calculated)
       
        System.out.print("Enter a circle radius: "); //Asks user for radius
        radius = input.nextDouble(); //collects double from user for radius
        if (radius < 0) { //If radius is negative
            System.out.println("Negative radii are illegal."); //print 'Negative Radii are illegal'
        } else { //If radius is postive
            circum = 2 * PI * radius; //calculates circumference
            System.out.println("The Circumference for this circle is: " + circum); //displays circumference
View Full Code Here

      writeFile = new BufferedWriter(out);
      for (int i = 0; i < 5; i++) {
        System.out.print("Enter student name: ");
        name = input.next();
        System.out.print("Enter test score: ");
        score = input.nextDouble();
        writeFile.write(name);
        writeFile.newLine();
        writeFile.write(String.valueOf(score));
        writeFile.newLine();
      }   
View Full Code Here

  public static void fahrenheitToCelsius() {
    double fTemp, cTemp;
    Scanner input = new Scanner(System.in);
   
    System.out.print("Enter a Fahrenheit temperature: ");
    fTemp = input.nextDouble();
    input.close();
   
    cTemp = (double)5/(double)9*(fTemp - 32);
    System.out.println("The Celsius temperature is " + cTemp);
  }
View Full Code Here

  public static void celsiusToFahrenheit() {
    double cTemp, fTemp;
    Scanner input = new Scanner(System.in);
   
    System.out.print("Enter a Celsius temperature: ");
    cTemp = input.nextDouble();
    input.close();
   
    fTemp = (double)9/(double)5*cTemp + 32;
    System.out.println("The Fahrenheit temperature is " + fTemp);
  }
View Full Code Here

        double principal; //Variable to hold first amount
        double years;     //Variable to hold year  amount
        double interest;  //Variable to hold interest amount
        double amount;    //Variable to hold end   amount
        System.out.print("Enter the amount: "); //Ask user for end amount
        amount = input.nextDouble(); //Collect end amount
        System.out.print("Enter the number of years: "); //Ask user for year amount
        years = input.nextDouble(); //Collect year amount
        System.out.print("Enter the interest rate: "); //Ask user for interest amount
        interest = input.nextDouble(); //Collect interest amount
        principal = amount / (1 + years * interest); //Calculate start amount
View Full Code Here

        double interest;  //Variable to hold interest amount
        double amount;    //Variable to hold end   amount
        System.out.print("Enter the amount: "); //Ask user for end amount
        amount = input.nextDouble(); //Collect end amount
        System.out.print("Enter the number of years: "); //Ask user for year amount
        years = input.nextDouble(); //Collect year amount
        System.out.print("Enter the interest rate: "); //Ask user for interest amount
        interest = input.nextDouble(); //Collect interest amount
        principal = amount / (1 + years * interest); //Calculate start amount
        System.out.print("The amount needed is: " + money.format(principal)); //Print end amount formated as currency
        }
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.