import java.Scanner; public class UserInput { //TO DO: Define promptForInt here //TO DO: Define promptForDouble here //TO DO:

import java.util.Scanner;

public class UserInput {

  //TO DO: Define promptForInt here

  //TO DO: Define promptForDouble here

  //TO DO: Define promptForYesNo here

  public static void main(String[] args) { 

    Scanner sc = new Scanner(System.in);

    //All values are initialised so code will compile and run

    int guess = -1;    //user’s guess (between 1 and 10)

    double percent = -1;  //a percentage (as a value between 0 and 1)

    boolean again = false; //do they want to go again?

    System.out.println(“Testing prompt for int… the number should be saved in guess.”);

    System.out.println(” – Enter ’60’ — should loop with error”);

    System.out.println(” – Enter ‘-6’ — should loop with error”);

    System.out.println(” – Enter ‘6’ and it should work”);

    // guess = promptForInt(sc, “Enter a number”, 1, 10);

    System.out.println(“Guess: ” + guess);

    System.out.println();

    System.out.println(“Testing prompt for double… the number should be saved in percent.”);

    System.out.println(” – Enter ’60’ — should loop with error”);

    System.out.println(” – Enter ‘-1’ — should loop with error”);

    System.out.println(” – Enter ‘0.5’ and it should work”);

    // percent = promptForDouble(sc, “Enter percent value”, 0.0, 1.0);

    System.out.println(“Percent: ” + percent);

    System.out.println();

    System.out.println(“Testing prompt for yes/no… the result is saved in again.”);

    System.out.println(” – Extend these boolean tests… add messages and verify your solution!”);

    System.out.println(” – Enter ‘yes’ and it should succeed”);

    // again = promptForYesNo(sc, “Play again?”);

    System.out.println(“Again: ” + again);

    System.out.println();

    System.out.println(” – Verify that it can also read in false…”);

    // again = promptForYesNo(sc, “Play again?”);

    System.out.println(“Again: ” + again);

    System.out.println();

    System.out.println(“Tests complete…”);     

  }

}

homeworkhelplocal
Calculate your essay price
(550 words)

Approximate price: $22

How it Works

1

It only takes a couple of minutes to fill in your details, select the type of paper you need (essay, term paper, etc.), give us all necessary information regarding your assignment.

2

Once we receive your request, one of our customer support representatives will contact you within 24 hours with more specific information about how much it'll cost for this particular project.

3

After receiving payment confirmation via PayPal or credit card – we begin working on your detailed outline, which is based on the requirements given by yourself upon ordering.

4

Once approved, your order is complete and will be emailed directly to the email address provided before payment was made!