Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package COMPUTER_ASSISTED_INSTRUCTION;;
- import java.util.Scanner;
- import java.util.Random;
- public class COMPUTER_ASSISTED_INSTRUCTION {
- private static final Random randomNumbers = new Random();// radom number generator
- private static final Scanner input = new Scanner (System.in);// class Scanner to accept user's input
- // TODO code application logic here
- public static void main(String[] args)
- {
- randomvalue();
- }//ends maain class
- public static void randomvalue()
- {
- int counter = 0;
- int totalScore = 0;
- double percentageScore = 0.0;
- for(int count = 1; count <=10; count++)
- {
- //pick random values
- int Num1 = 1 + randomNumbers.nextInt(9);//first numbner generator
- int Num2 = 1 + randomNumbers.nextInt(9);//Second number generator
- int product = Num1 * Num2; // initialize sum product of first and second number
- //prompt statement
- System.out.printf("How much is %d times %d:\n",Num1,Num2);
- // assign users answer to variable product
- product = input.nextInt();
- if (product == Num1 * Num2)
- {
- totalScore = 1 + totalScore;
- int responce = 1 + randomNumbers.nextInt(4);
- switch (responce)
- {
- case 1:
- System.out.println("Very Good!");
- break;
- case 2:
- System.out.println("Excellent!");
- break;
- case 3:
- System.out.println("Nice Work!");
- break;
- case 4:
- System.out.println("Keep up the Good work!");
- break;
- }
- }
- else
- {
- totalScore = 0 + totalScore;
- int responce = 1 + randomNumbers.nextInt(4);
- switch (responce)
- {
- case 1:
- System.out.println("Answer not correct. Please try again!");
- break;
- case 2:
- System.out.println("Wrong answer. Try once more!");
- break;
- case 3:
- System.out.println("Incorrect answer. Don't give up!");
- break;
- case 4:
- System.out.println("Nooo. Keep trying!");
- break;
- }
- }
- percentageScore = (totalScore / 10.0) * 100;
- counter++;
- }
- if (percentageScore < 75 && counter >= 10)
- {
- System.out.println("You need to ask your teacher for more help");
- }
- else if(percentageScore > 75 && counter >= 10)
- {
- System.out.println("Congratulation, you are ready to go to the next level");
- }
- }
- //end of class declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment