Assignment 58, One Shot Hi-Lo
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: Guess
///File Name: Guess3.java
///Date Finshed: 12/3/15
import java.util.Scanner;
import java.util.Random;
public class Guess3
{
public static void main (String[] args)
{
Scanner siri = new Scanner(System.in);
Random r = new Random();
int x, s;
s = 1 + r.nextInt(100);
System.out.println("Let's play a guessing game, I'm thinking of a number between 1-100.");
System.out.print("Your guess: ");
x = siri.nextInt();
if (s == x)
System.out.println("You guessed the number right!");
if (s > x)
System.out.println("You guessed too low.");
if (s < x)
System.out.println("You guessed too high.");
}}
Picture of the output