There are some situations where you find yourself using the phone of a friend, colleague or your significant other. For…
The next big thing in the technology world is artificial intelligence (AI). Big tech organisations like Apple and Google are…
Technology is one of the most dynamic industries in the world. It keeps changing and improving at a geometric sequence.…
Smartphone batteries have been reinforced over the years to last longer with lithium batteries. Notwithstanding, there are some phones whose…
A Computer Numerical Controlled (CNC) machine may have more than one motion type that it uses, but there are three…
Program that prompts the user to enter the first 9 digits of an ISBN number and displays the 10-digit ISBN…
It is a New Year and you may probably want to replace your smartphone you have been using for several…
CNC milling control machineHave you ever asked yourself how machines in a factory know exactly when to stop making the…
Program that randomly generates an addition question with two integers less than 100.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> */<br /><br />import java.util.Scanner;<br /><br />public class Ex03_10 {<br /> public static void main(String[] args) {<br /> // Generate two integers less than 100<br /> int number1 = (int) (Math.random() * 100);<br /> int number2 = (int) (Math.random() * 100);<br /><br /> // Prompt the user to answer "What is number1 + number2?"<br /> System.out.print("What is " + number1 + " + " + number2 + "? ");<br /> Scanner input = new Scanner(System.in);<br /> int answer = input.nextInt();<br /> // Grade the answer and display the result<br /> if (number1 + number2 == answer) {<br /> System.out.println("You are correct!");<br /> } else {<br /> System.out.println("Your answer is wrongn" + number1 + " + " + number2 + " is "<br /> + (number1 + number2));<br /> }<br /> }<br />}<br /> |
Sample program runClick here to see other solutions…
Technology is an important part of your lives. We can barely do without it. Consequently, you have developed some perennial…
If you’re familiar with MS-DOS at all, you’ll recall that it’s a command-driven operating system that performs functions issued at…
Program that prompts the user to enter an integer for today’s day of the week (Sunday is 0, Monday is…