Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a) The use of computers in education is referred to as computer-assisted instruc

ID: 3733569 • Letter: A

Question

a) The use of computers in education is referred to as computer-assisted instruction (CAl). Write a program that will help an elementary school student learn multiplication. Use the rand function to produce two positive one-digit integers The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student's answer. If it's correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again." and let the student try the same question repeatedly until the student finally gets it right. A separate function should be used to generate each new question This function should be called once when the application begins execution and each time the user answers the question correctly

Explanation / Answer

import java.util.Scanner;

public class EducationSystem {

int firstNo = 0, secNo = 0, res;

public static void main(String args[]) {

int userRes = -1;

String more = "";

EducationSystem es = new EducationSystem();

// To read input from keyboard

Scanner scan = new Scanner(System.in);

System.out.println("-------------Eduaction System----------------");

do {

System.out.println(es.generateQuestion());

es.res = es.firstNo * es.secNo;

do {

try {

// reading the user result

userRes = Integer.parseInt(scan.nextLine());

} catch (NumberFormatException e) {

System.err.println("Please enter number in proper format!");

}

// comparing the result

if (es.res != userRes) {

System.out.println("No. Please try again");

} else {

System.out.println("Yes.");

}

} while (es.res != userRes);// continuing while user enters correct result

System.out.println("Press y/Y for more question. Anything else to exit.");

more = scan.nextLine();

} while (more.equalsIgnoreCase("y"));// asking for more questions

System.out.println("---------------Thank you---------------------");

scan.close();

// complete

}

public String generateQuestion() {

// Generating the random numbers

firstNo = ((int) (Math.random() * 10));

secNo = ((int) (Math.random() * 10));

return "How much is " + firstNo + " times " + secNo;

}

}