Guest User

Untitled

a guest
Aug 27th, 2014
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.07 KB | None | 0 0
  1.  
  2. package COMPUTER_ASSISTED_INSTRUCTION;;
  3.  
  4.  
  5. import java.util.Scanner;
  6. import java.util.Random;
  7.   public class COMPUTER_ASSISTED_INSTRUCTION {
  8.  
  9.     private static final Random randomNumbers = new Random();// radom number generator
  10.     private static final Scanner input = new Scanner (System.in);// class Scanner to accept user's input
  11.  
  12.     // TODO code application logic here
  13.     public static void main(String[] args)
  14.     {
  15.  
  16.        randomvalue();
  17.     }//ends maain class
  18.  
  19.     public static void randomvalue()
  20.  
  21.     {
  22.         int counter = 0;
  23.         int totalScore = 0;
  24.         double percentageScore = 0.0;
  25.  
  26.         for(int count = 1; count <=10; count++)
  27.         {
  28.             //pick random values
  29.             int Num1 = 1 + randomNumbers.nextInt(9);//first numbner generator
  30.             int Num2 = 1 + randomNumbers.nextInt(9);//Second number generator
  31.             int product = Num1 * Num2; // initialize sum product of first and second number
  32.             //prompt statement
  33.             System.out.printf("How much is %d times %d:\n",Num1,Num2);
  34.             // assign users answer to variable product
  35.             product = input.nextInt();
  36.             if (product == Num1 * Num2)
  37.             {
  38.                 totalScore = 1 + totalScore;
  39.                 int responce = 1 + randomNumbers.nextInt(4);
  40.  
  41.                 switch (responce)
  42.                 {
  43.                     case 1:
  44.                     System.out.println("Very Good!");
  45.                     break;
  46.                     case 2:
  47.                     System.out.println("Excellent!");
  48.                     break;
  49.  
  50.                     case 3:
  51.                     System.out.println("Nice Work!");
  52.                     break;
  53.  
  54.                     case 4:
  55.                     System.out.println("Keep up the Good work!");
  56.                     break;
  57.                 }
  58.             }
  59.             else
  60.             {
  61.                 totalScore = 0 + totalScore;
  62.                 int responce = 1 + randomNumbers.nextInt(4);
  63.  
  64.                 switch (responce)
  65.                 {
  66.                     case 1:
  67.                     System.out.println("Answer not correct. Please try again!");
  68.                     break;
  69.                     case 2:
  70.                     System.out.println("Wrong answer. Try once more!");
  71.                     break;
  72.                     case 3:
  73.                     System.out.println("Incorrect answer. Don't give up!");    
  74.                     break;
  75.                     case 4:
  76.                     System.out.println("Nooo. Keep trying!");
  77.                     break;
  78.                 }
  79.             }
  80.             percentageScore = (totalScore / 10.0) * 100;
  81.             counter++;
  82.         }
  83.        
  84.  
  85.         if (percentageScore < 75 && counter >= 10)
  86.         {
  87.             System.out.println("You need to ask your teacher for more help");
  88.         }
  89.         else if(percentageScore > 75 && counter >= 10)
  90.         {    
  91.             System.out.println("Congratulation, you are ready to go to the next level");
  92.         }
  93.                
  94.     }
  95. //end of class declaration
  96. }
Advertisement
Add Comment
Please, Sign In to add comment