Question

In: Computer Science

IN JAVA Part 1 The use of computers in education is referred to as computer-assisted instruction...

IN JAVA

Part 1

The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to produce two positive one-digit integers (you will need to look up how to do this). 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.>again." and let the student try the same question repeatedly until the student finally gets it right. A separate method should be used to generate each new question. This method should be called once when the application begins execution and each time the user answers the question correctly.

Part 2

Modify the program from Part 1 so that various comments are displayed for each answer as follows:

Possible responses to a correct answer:

Very good!
Excellent!
Nice work!
Keep up the good work!

Possible responses to an incorrect answer:

No. Please try again.
Wrong. Try once more.
Don’t give up!
No. Keep trying.

Use random-number generation to choose a number from 1 to 4 that will be used to select one of the four appropriate responses to each correct or incorrect answer. Use a switch statement to issue the responses.

Part 3

Modify the program from Part 2 to use your question generation method to ask the student 10 different questions. Give students only one chance at answering each question. Count the number of correct and incorrect responses typed by the student. After the program has asked 10 questions, and the student types 10 answers, your program should calculate the percentage that are correct. If the percentage is lower than 75%, display "Please ask your teacher for extra help.", then reset the program so another student can try it. If the percentage is 75% or higher, display "Congratulations, you are ready to go to the next level!", then reset the program so another student can try it.

Part 4

Modify the program from Part 3 to allow the user to enter a difficulty level. At a difficulty level of 1, the program should use only single-digit numbers in the problems; at a difficulty level of 2, numbers as large as two digits, and so on. Allow for four levels of difficulty.

Part 5

Modify the program from Part 4 to allow the user to pick a type of arithmetic problem to study. An option of 1 means addition problems only, 2 means multiplication problems only, 3 means subtraction problems only, 4 means division problems only and 5 means a random mixture of all these types.

Solutions

Expert Solution

import java.util.*;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.security.SecureRandom;
class computer_assisted_instruction
{
   private static DecimalFormat df2 = new DecimalFormat("#.##");
   public static void main(String arg[])
   {
       while(true)
       {
           On_go();
       }
   }
   static void On_go()
   {

           System.out.println("Choose the difficulty level");
           System.out.println("Level-1");
           System.out.println("Level-2");
           System.out.println("Level-3");
           System.out.println("Level-4");
           Scanner sc=new Scanner(System.in);
           int level=sc.nextInt();
           System.out.println("Type of Arithmatic");

           System.out.println("Addition-1");
           System.out.println("Multiplication-2");
           System.out.println("Subtraction-3");
           System.out.println("Division-4");
           System.out.println("Mixer of all-5");
           int type_ar=sc.nextInt();

           solve_problem(level,type_ar);
   }

   static void solve_problem(int level,int type_ar)
   {
       int counter=0;
      
       switch (type_ar) {
case 1:
for(int i=1;i<=10;i++)
           {
               counter+=addition(level);
           }
break;
case 2:
for(int i=1;i<=10;i++)
           {
               counter+=multiplication(level);
           }
break;
case 3:
for(int i=1;i<=10;i++)
           {
               counter+=substraction(level);
           }
break;
case 4:
for(int i=1;i<=10;i++)
           {
               counter+=division(level);
           }

break;
case 5:
for(int i=1;i<=10;i++)
           {
               int ran=Random(1,4);
               if(ran==1)
               {
                   counter+=addition(level);
               }
               if(ran==2)
               {
                   counter+=multiplication(level);
               }
               if(ran==3)
               {
                   counter+=substraction(level);
               }
               if(ran==4)
               {
                   counter+=division(level);
               }
           }
break;

default:
System.out.println("Invalid Number");
return;
  
}


  

       if((double)((double)counter/10)*100>=(double)75)
       {
           System.out.println("Congratulations, you are ready to go to the next level!");
       }
       else
       {
           System.out.println("Please ask your teacher for extra help");
       }
   }

   static int addition(int level)
   {
       int a=0;
       int b=0;
       if(level==1)
       {
           a=Random(0,9);
           b=Random(0,9);
       }
       if(level==2)
       {
           a=Random(10,99);
           b=Random(10,99);
       }
       if(level==3)
       {
           a=Random(100,999);
           b=Random(100,999);
       }
       if(level==4)
       {
           a=Random(1000,9999);
           b=Random(1000,9999);
       }
       Scanner sc=new Scanner(System.in);
       System.out.println("How much is "+a+" plus "+b);
       int answer=sc.nextInt();
       if(answer==a+b)
           {
                   int choose=Random(1,4);
                   if(choose==1)
               {
                   System.out.println("Very good!");
               }
               if(choose==2)
                   {
                           System.out.println("Excellent!");
                   }
                   if(choose==3)
               {
                   System.out.println("Nice work!");
               }
               if(choose==4)
               {
                   System.out.println("Keep up the good work!");
                   }
                   return 1;
           }
           else
           {


               int ch=Random(1,4);
                   if(ch==1)
                   {
                   System.out.println("No. Please try again.");
                   }
               if(ch==2)
                       {
                           System.out.println("Wrong. Try once more.");
                       }
                   if(ch==3)
                   {
                   System.out.println("Don't give up!");
                   }
               if(ch==4)
                   {
                   System.out.println("No. Keep trying");
                       }


               while(true)
               {
                   int ans=sc.nextInt();
                  
                   if(ans==a+b)
                   {
                       int choose=Random(1,4);
                   if(choose==1)
                   {
                   System.out.println("Very good!");
                   }
               if(choose==2)
                       {
                           System.out.println("Excellent!");
                       }
                   if(choose==3)
                   {
                   System.out.println("Nice work!");
                   }
               if(choose==4)
                   {
                   System.out.println("Keep up the good work!");
                       }

                   return 0;
                   }
                   else
                   {
                       int choose=Random(1,4);
                   if(choose==1)
                   {
                   System.out.println("No. Please try again.");
                   }
               if(choose==2)
                       {
                           System.out.println("Wrong. Try once more.");
                       }
                   if(choose==3)
                   {
                   System.out.println("Don't give up!");
                   }
               if(choose==4)
                   {
                   System.out.println("No. Keep trying");
                       }
                   }
               }
           }

   }

   static int substraction(int level)
   {
       int a=0,b=0;
           if(level==1)
       {
           a=Random(0,9);
           b=Random(0,9);
       }
       if(level==2)
       {
           a=Random(10,99);
           b=Random(10,99);
       }
       if(level==3)
       {
           a=Random(100,999);
           b=Random(100,999);
       }
       if(level==4)
       {
           a=Random(1000,9999);
           b=Random(1000,9999);
       }
       Scanner sc=new Scanner(System.in);
       System.out.println("How much is "+a+" subtract "+b);
       int answer=sc.nextInt();
       if(answer==b-a)
           {
                   int choose=Random(1,4);
                   if(choose==1)
               {
                   System.out.println("Very good!");
               }
               if(choose==2)
                   {
                           System.out.println("Excellent!");
                   }
                   if(choose==3)
               {
                   System.out.println("Nice work!");
               }
               if(choose==4)
               {
                   System.out.println("Keep up the good work!");
                   }
                   return 1;
           }
           else
           {
               int ch=Random(1,4);
                   if(ch==1)
                   {
                   System.out.println("No. Please try again.");
                   }
               if(ch==2)
                       {
                           System.out.println("Wrong. Try once more.");
                       }
                   if(ch==3)
                   {
                   System.out.println("Don't give up!");
                   }
               if(ch==4)
                   {
                   System.out.println("No. Keep trying");
                       }
               while(true)
               {
                   int ans=sc.nextInt();
                  
                   if(ans==b-a)
                   {
                       int choose=Random(1,4);
                   if(choose==1)
                   {
                   System.out.println("Very good!");
                   }
               if(choose==2)
                       {
                           System.out.println("Excellent!");
                       }
                   if(choose==3)
                   {
                   System.out.println("Nice work!");
                   }
               if(choose==4)
                   {
                   System.out.println("Keep up the good work!");
                       }

                   return 0;
                   }
                   else
                   {
                       int choose=Random(1,4);
                   if(choose==1)
                   {
                   System.out.println("No. Please try again.");
                   }
               if(choose==2)
                       {
                           System.out.println("Wrong. Try once more.");
                       }
                   if(choose==3)
                   {
                   System.out.println("Don't give up!");
                   }
               if(choose==4)
                   {
                   System.out.println("No. Keep trying");
                       }
                   }
               }
           }
   }

   static int multiplication(int level)
   {
       int a=0,b=0;
       if(level==1)
       {
           a=Random(0,9);
           b=Random(0,9);
       }
       if(level==2)
       {
           a=Random(10,99);
           b=Random(10,99);
       }
       if(level==3)
       {
           a=Random(100,999);
           b=Random(100,999);
       }
       if(level==4)
       {
           a=Random(1000,9999);
           b=Random(1000,9999);
       }
       Scanner sc=new Scanner(System.in);
       System.out.println("How much is "+a+" times "+b);
       int answer=sc.nextInt();
       if(answer==b*a)
           {
                   int choose=Random(1,4);
                   if(choose==1)
               {
                   System.out.println("Very good!");
               }
               if(choose==2)
                   {
                           System.out.println("Excellent!");
                   }
                   if(choose==3)
               {
                   System.out.println("Nice work!");
               }
               if(choose==4)
               {
                   System.out.println("Keep up the good work!");
                   }
                   return 1;
           }
           else
           {
               int ch=Random(1,4);
                   if(ch==1)
                   {
                   System.out.println("No. Please try again.");
                   }
               if(ch==2)
                       {
                           System.out.println("Wrong. Try once more.");
                       }
                   if(ch==3)
                   {
                   System.out.println("Don't give up!");
                   }
               if(ch==4)
                   {
                   System.out.println("No. Keep trying");
                       }

               while(true)
               {
                   int ans=sc.nextInt();
                  
                   if(ans==b*a)
                   {
                       int choose=Random(1,4);
                   if(choose==1)
                   {
                   System.out.println("Very good!");
                   }
               if(choose==2)
                       {
                           System.out.println("Excellent!");
                       }
                   if(choose==3)
                   {
                   System.out.println("Nice work!");
                   }
               if(choose==4)
                   {
                   System.out.println("Keep up the good work!");
                       }

                   return 0;
                   }
                   else
                   {
                       int choose=Random(1,4);
                   if(choose==1)
                   {
                   System.out.println("No. Please try again.");
                   }
               if(choose==2)
                       {
                           System.out.println("Wrong. Try once more.");
                       }
                   if(choose==3)
                   {
                   System.out.println("Don't give up!");
                   }
               if(choose==4)
                   {
                   System.out.println("No. Keep trying");
                       }
                   }
               }
           }
   }

   static int division(int level)
   {
       float a=0,b=0;
if(level==1)
       {
           a=Random(1,9);
           b=Random(1,9);
       }
       if(level==2)
       {
           a=Random(10,99);
           b=Random(10,99);
       }
       if(level==3)
       {
           a=Random(100,999);
           b=Random(100,999);
       }
       if(level==4)
       {
           a=Random(1000,999);
           b=Random(1000,999);
       }
       Scanner sc=new Scanner(System.in);
      

       System.out.println("How much is "+a+" Divide "+b);
       String answer=sc.nextLine();
       // System.out.println(df2.format(b/a));
       if(answer.equals(df2.format(b/a)))
           {
                   int choose=Random(1,4);
                   if(choose==1)
               {
                   System.out.println("Very good!");
               }
               if(choose==2)
                   {
                           System.out.println("Excellent!");
                   }
                   if(choose==3)
               {
                   System.out.println("Nice work!");
               }
               if(choose==4)
               {
                   System.out.println("Keep up the good work!");
                   }
                   return 1;
           }
           else
           {
               int ch=Random(1,4);
                   if(ch==1)
                   {
                   System.out.println("No. Please try again.");
                   }
               if(ch==2)
                       {
                           System.out.println("Wrong. Try once more.");
                       }
                   if(ch==3)
                   {
                   System.out.println("Don't give up!");
                   }
               if(ch==4)
                   {
                   System.out.println("No. Keep trying");
                       }
               while(true)
               {
                   String ans=sc.nextLine();
                  //System.out.println(df2.format(b/a));
                  
                   if(ans.equals(df2.format(b/a)))
                   {
                       int choose=Random(1,4);
                   if(choose==1)
                   {
                   System.out.println("Very good!");
                   }
               if(choose==2)
                       {
                           System.out.println("Excellent!");
                       }
                   if(choose==3)
                   {
                   System.out.println("Nice work!");
                   }
               if(choose==4)
                   {
                   System.out.println("Keep up the good work!");
                       }

                   return 0;
                   }
                   else
                   {
                       int choose=Random(1,4);
                   if(choose==1)
                   {
                   System.out.println("No. Please try again.");
                   }
               if(choose==2)
                       {
                           System.out.println("Wrong. Try once more.");
                       }
                   if(choose==3)
                   {
                   System.out.println("Don't give up!");
                   }
               if(choose==4)
                   {
                   System.out.println("No. Keep trying");
                       }
                   }
               }
           }
   }


       public static int Random(int min, int max){
           SecureRandom rand = new SecureRandom();
           int x = (int)(rand.nextDouble()*((max-min)+1))+min;
           return x;
           }

}


Related Solutions

6.35 (Computer-Assisted Instruction) The use of computers in education is referred to as computer-assisted instruction (CAI)....
6.35 (Computer-Assisted Instruction) The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object 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...
USE C language :- The use of computers in education is referred to as computer-assisted instruction...
USE C language :- The use of computers in education is referred to as computer-assisted instruction (CAI). 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...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of its corporate clients. It offers courses in the clients’ offices on the clients’ equipment. The only major expense FTS incurs is instructor salaries; it pays instructors $5,300 per course taught. FTS recently agreed to offer a course of instruction to the employees of Novak Incorporated at a price of $490 per student. Novak estimated that 20 students would attend the course. Base your answers...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of its corporate clients. It offers courses in the clients’ offices on the clients’ equipment. The only major expense FTS incurs is instructor salaries; it pays instructors $5,300 per course taught. FTS recently agreed to offer a course of instruction to the employees of Novak Incorporated at a price of $490 per student. Novak estimated that 20 students would attend the course. Base your answers...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of its corporate clients. It offers courses in the clients’ offices on the clients’ equipment. The only major expense FTS incurs is instructor salaries; it pays instructors $6,000 per course taught. FTS recently agreed to offer a course of instruction to the employees of Novak Incorporated at a price of $700 per student. Novak estimated that 20 students would attend the course. a. Relative to...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of its corporate clients. It offers courses in the clients’ offices on the clients’ equipment. The only major expense FTS incurs is instructor salaries; it pays instructors $6,000 per course taught. FTS recently agreed to offer a course of instruction to the employees of Novak Incorporated at a price of $700 per student. Novak estimated that 20 students would attend the course. Part 3: FTS...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of...
Franklin Training Services (FTS) provides instruction on the use of computer software for the employees of its corporate clients. It offers courses in the clients’ offices on the clients’ equipment. The only major expense FTS incurs is instructor salaries; it pays instructors $6,000 per course taught. FTS recently agreed to offer a course of instruction to the employees of Novak Incorporated at a price of $700 per student. Novak estimated that 20 students would attend the course. Base your answers...
The goal of Java program(s) implemented as part of this assignment is: 1. To use for,...
The goal of Java program(s) implemented as part of this assignment is: 1. To use for, while, do-while loops to solve the given problem(s) 2. Write custom method(s) Note: Be sure to document your code thoroughly. In other words, you must comment each pertinent line of code to briefly state what it is intending to do. Requirement-1 In the Requirement-1 you will create a program named ‘ComputeCompoundInterest, that will compute compound interest using the formula as follows: amount = principal...
Java. Part 1 of 4 - Amusement Park Programming Project Requirements: Use the Java selection constructs...
Java. Part 1 of 4 - Amusement Park Programming Project Requirements: Use the Java selection constructs (if and if else). Use the Java iteration constructs (while, do, for). Use Boolean variables and expressions to control iterations. Proper error handling. Class: Ticket – models admission tickets. Instance Fields: number : long – identify the unique ticket. category : String – store the category of the ticket. holder : String – store the name of the person who purchased the ticket. date...
Part 1 – Instruction - You will prepare the following in excel: 1. General Journal a....
Part 1 – Instruction - You will prepare the following in excel: 1. General Journal a. Journal entries – full proper journal entry with descriptions b. Post entries to ledger 2. Ledger – T accounts a. Show beginning balance b. Post all activity – make sure to include reference to journal entry c. Show ending balance 3. Trial Balance a. Unadjusted Trial Balance The following transaction occurred for Agape Pet Supply Co. during the period ended 12/31/x1. They provide services...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT