Elijo4257 / Java-JavaScript-projects

0 stars 0 forks source link

Cost Breakdown #1

Open Elijo4257 opened 11 months ago

Elijo4257 commented 11 months ago

This projects aims to breakdown the cost of an item into different denominations.

Elijo4257 commented 11 months ago

import java.util.Scanner; public class doloop { public static void main(String[]args){ Scanner scan = new Scanner(System.in); int rand = ((int)(Math.random()100)) + 1; int randTwo = ((int)(Math.random()100)) + 1;

    int correctGuess = ((rand + randTwo)/2); 
    System.out.print("guess a number from 1 to 100 that is in the middle "
            + "of two random numbers: ");
    int guess = scan.nextInt();

    do
    {

    if (guess > correctGuess){
        System.out.print("your guess is high. Guess again: ");
        guess = scan.nextInt();}
    if (guess < correctGuess){
        System.out.print("your guess is too low. Guess again: ");
        guess = scan.nextInt();
    }

    }while (guess != correctGuess);
System.out.println (" you guessed the middle number correctly!. "
        + "the two numbers were");
}

}