Question: 1) Evaluate the following loops: a) int i = 1; while (i
1) Evaluate the following loops:
a) int i = 1;
while (i<=10) {
System.out.println("Nevermore");
i = i + 2;
}
b) int i = 1;
do {
System.out.println(i);
i++;
} while (i < 10);
2) Computers are playing an increasing role in education. create a java program that will help elementary school children learn multiplication. Use the Random class in the java.util package to produce two positive one-digit integers. The format to generating this number is as follows:
import java.util.* ;
/*** in your progam ***/
Random myRandomNumber = new Random();
int myOneDigitNumber = Math.abs( myRandomNumber.nextInt() % 10 );
The Math class in the java.lang package is also used to convert the number to an absolute value. The modulus is used to get a single digit number.
Use this one digit number produced to type the question as follows:
How much is 6 times 7?
The student then types the answer. Your program checks the student's answer. If it is correct, print "Very Good!" and then ask another multiplication question. If the answer is wrong, print "No. Please try again." and then let the student try the same question again repeatedly until the student finally gets it right. Enter a -1 to exit program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
