Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Zach Enz
- //Home Assignment 3 [3.5]
- import java.util.Scanner;
- import java.util.Random;
- class Home {
- public static void main(String[] args) {
- //Declare Variables
- int random, i;
- i = 1;
- int total = 0;
- Scanner scan = new Scanner(System.in);
- Random generator = new Random();
- while (i0. < 4)
- {
- random = generator.nextInt(9);
- System.out.println("Number" + i + ": " + random);
- i += 1;
- total = total + random;
- }
- System.out.println("Enter total");
- if (scan.nextInt() == total) {
- System.out.println("Correct");
- } else {
- System.out.println("Wrong");
- }
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement