Program that generates two integers under 100 and prompts the user to enter the sum of these two integers.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> */<br /><br />import java.util.Scanner;<br /><br />public class Ex03_04 {<br /> public static void main(String[] args) {<br /> int number1 = (int)(System.currentTimeMillis() % 100);<br /> int number2 = (int)(System.currentTimeMillis() / 7 % 100);<br /> Scanner input = new Scanner(System.in);<br /> System.out.print("What is " + number1 + " + " + number2 + "? ");<br /> int answer = input.nextInt();<br /> System.out.println(number1 + " + " + number2 + " = " + answer + " is " <br /> + (number1 + number2 == answer));<br /> } <br />}<br /> |
Sample run |
Click here to see other solutions to Introduction to Java Programming.