In: Computer Science
The use of computers in education is referred to as computer-assisted instruction (CAI). More sophisticated CAI systems monitor the student’s performance over a period of time. The decision to begin a new topic is often based on the student’s success with previous topics. Modify the following auxiliary program (Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. Use rand to produce two positive one-digit integers. It should then type a question such as: How much is 8 * 9? The student then types the answer. Your program checks the student’s answer. If it is correct, print “Very good!” and then ask another addition 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. Terminate the program when the student has 5 right answers.) to count the number of correct and incorrect responses typed by the student. After the student types 5 answers, your program should calculate the percentage of correct responses. If the percentage is lower than 75 percent, your program should print “Please ask for extra help” and then terminate. If the percentage is 75 percent or higher, your program should print “Good work!” and then terminate.
I am programming student so please keep code simple enough that I can learn from it thanks
import java.util.Scanner; //importing Scanner
class
import java.util.Random; //importing random
class. to generate random numbers
class primary{
public static void main(String...args){
Scanner input=new
Scanner(System.in); //create object for Scanner
class
Random randomnumber =
new Random(); //create object for
random class
int
right_answercount=0;
//number of correct answers count
int
wrong_answercount=0;
//number of wrong answers count
int
total_questions=0;
// total number of questions
int
percentage;
// this variable is used for storing percentage..
while(right_answercount<5){
//it execute loop until 5 right answers
int
num1=randomnumber.nextInt(10);
//taking random number and assign to num1 variable
int
num2=randomnumber.nextInt(10);
//taking random number and assign to num2 variable
System.out.println("how
much"+num1+"*"+num2+"?"); //asaking
question
int
useranswer=input.nextInt();
//taking answer from user
int
total=num1*num2;
//calculating correct answer
if(total==useranswer){
//if user answer is correct if block execute
right_answercount=right_answercount+1; //increament
right_answer
System.out.println("very good");}
else
if(total!=useranswer){
//if user answer is wrong.else if block execute
wrong_answercount=wrong_answercount+1; //increament
wrong_answers
System.out.println("No. Please try again.");}
total_questions=total_questions+1;
//increamenting toatal+questions
}
System.out.println("Total number of questions
you attemted are : "+total_questions); //printing total no.of
questions attempted
System.out.println("correct answers are:
"+right_answercount); // printing
total no.of questions are
correct
System.out.println("Wrong answers are:
"+wrong_answercount); //
printing total no.of questions are wrong
percentage=(100*right_answercount)/total_questions;
//calculating percentage
if(percentage<75){
//if percentage is <75.if block execute
System.out.println("Please ask for extra
help..");}
else
if(percentage>=75){
//if percentage is >=75.else if block execute
System.out.println("Good work!");}
}}