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

JAVA OOP Thank you Write a program that teaches arithmetic to a young child. The

ID: 3839199 • Letter: J

Question

JAVA OOP Thank you

Write a program that teaches arithmetic to a young child. The program tests addition and subtraction. In Level 1, it tests only addition of whole numbers less than ten whose sum is less than ten. In level 2, it tests addition of arbitrary single digit whole numbers. In level 3, it tests subtraction of single digit whole numbers with a non-negative difference.

Generate random problems and get the players' input. The player gets up to two tries per problem. Advance from one level to the next when the player has achieved a score of five correct answers.

Explanation / Answer


import java.io.*;
import java.util.*;
public class Teaching {
   static int totalscore=0;
   static Random r=new Random();
   static Scanner sc=new Scanner(System.in);
   public static void main(String[] args) {
       // TODO Auto-generated method stub
       int score1=0;
       int score2=0;
       int score3=0;
       score1=level1();
       if(score1>=5){
           score2=level2();
       }else{
           System.out.println("please try level 1 again:");
       }
       if(score2>=10){
           score3=level3();
       }else{
           System.out.println("please start game again:");
       }
       if(score3>=15)
           System.out.println("Thank you:");
       else
           System.out.println("try again:");
          
   }
   private static int level3() {
       System.out.println("IN LEVEL 2: Test in Arbitary single digit subtraction:");
       System.out.println("student wins the game if he scores 5 in level 3");
       int arbnum;
       int first;
       int second;
       int result=0;
       for(int i=1;i<=10;i++){
           System.out.println("Question number="+i);
           arbnum=r.nextInt(9)+1;
           int j=1;
           while(j<3){
               System.out.println("chance number="+j);
                   System.out.println("enter first digit for arbitary subtraction number for "+arbnum);
                   first=sc.nextInt();
                   System.out.println("enter second digit for arbitary subtraction number for "+arbnum);
                   second=sc.nextInt();
                   result=first-second;
                   if(result==arbnum){
                       System.out.println("correct answer:");
                       totalscore++;
                       break;
                   }else{
                       System.out.println("wrong answer:");
                   }
                   j++;
           }
           if(totalscore==15){
               System.out.println("your score is "+totalscore+":you successful crossed level 3:");
               System.out.println("CONGTATULATIONS YOU WON THE GAME:");
               break;
           }
           if(i==10){
                   System.out.println("question over:");
                   System.out.println("totalscore="+totalscore);
                   System.out.println("GAME OVER!!!!!!!!!");
               }
       }
       return totalscore;
      
      
   }
   private static int level2() {
       System.out.println("IN LEVEL 2: Test in Arbitary single digit addition:");
       System.out.println("student enters level 3 if scores 5 in level 2");
       int arbnum;
       int first;
       int second;
       int result=0;
       for(int i=1;i<=10;i++){
           System.out.println("Question number="+i);
           arbnum=r.nextInt(9)+1;
           int j=1;
           while(j<3){
               System.out.println("chance number="+j);
                   System.out.println("enter first digit for arbitary addition number for "+arbnum);
                   first=sc.nextInt();
                   System.out.println("enter second digit for arbitary addition number for "+arbnum);
                   second=sc.nextInt();
                   result=first+second;
                   if(result==arbnum){
                       System.out.println("correct answer:");
                       totalscore++;
                       break;
                   }else{
                       System.out.println("wrong answer:");
                   }
                   j++;
           }
           if(totalscore==10){
               System.out.println("your score is "+totalscore+":you successful crossed level 2:");
               break;
           }
           if(i==10){
                   System.out.println("question over:");
                   System.out.println("totalscore="+totalscore);
                   System.out.println("GAME OVER!!!!!!!!!");
               }
       }
       return totalscore;
      
   }
   public static int level1(){
       System.out.println("IN LEVEL 1: Test in Addition and Subtraction");
       System.out.println("student enters level2 if scores 5 in level 1");
       int result=0;
       int big=0;
       int small=0;
       int answer;
       String op;
       for(int i=1;i<=10;i++){
          
           System.out.println("Question number="+i);
           int first=r.nextInt(10)+0;
           int second=r.nextInt(10)+0;
           if(first>second){
               big=first;
               small=second;
           }else{
               big=second;
               small=first;
           }
             
           boolean operator=r.nextBoolean();
           if(operator==true)
               op="addition";
           else
               op="subtraction";
           if(operator==true)
           result=   big+small;
           else
           result=   big-small;
           int j=1;
           while(j<3){
               System.out.println("chance number="+j);
               System.out.println("what is "+op+ " of "+big+" and "+small);
               answer=sc.nextInt();
               if(answer==result){
                   System.out.println("correct answer:");
                   totalscore++;
               break;
               }else{
                   System.out.println("wrong answer:");
               }
               j++;
           }
          
           if(totalscore==5){
               System.out.println("your score is "+totalscore+":you successful crossed level 1:");
               break;
           }
           if(i==10){
               System.out.println("question over:");
               System.out.println("totalscore="+totalscore);
               System.out.println("GAME OVER!!!!!!!!!");
           }
      
       }
      
       return totalscore;
   }
}

output:
IN LEVEL 1:
Test in Addition and Subtraction
student enters level2 if scores 5 in level 1
Question number=1
chance number=1
what is addition of 8 and 6
14
correct answer:
Question number=2
chance number=1
what is addition of 1 and 0
1
correct answer:
Question number=3
chance number=1
what is subtraction of 1 and 0
1
correct answer:
Question number=4
chance number=1
what is addition of 3 and 1
4
correct answer:
Question number=5
chance number=1
what is subtraction of 7 and 6
1
correct answer:
your score is 5:you successful crossed level 1:
IN LEVEL 2:
Test in Arbitary single digit addition:
student enters level 3 if scores 5 in level 2
Question number=1
chance number=1
enter first digit for arbitary addition number for 7
4
enter second digit for arbitary addition number for 7
3
correct answer:
Question number=2
chance number=1
enter first digit for arbitary addition number for 5
2
enter second digit for arbitary addition number for 5
3
correct answer:
Question number=3
chance number=1
enter first digit for arbitary addition number for 4
2
enter second digit for arbitary addition number for 4
2
correct answer:
Question number=4
chance number=1
enter first digit for arbitary addition number for 6
3
enter second digit for arbitary addition number for 6
3
correct answer:
Question number=5
chance number=1
enter first digit for arbitary addition number for 6
3
enter second digit for arbitary addition number for 6
3
correct answer:
your score is 10:you successful crossed level 2:
IN LEVEL 2:
Test in Arbitary single digit subtraction:
student wins the game if he scores 5 in level 3
Question number=1
chance number=1
enter first digit for arbitary subtraction number for 6
10
enter second digit for arbitary subtraction number for 6
4
correct answer:
Question number=2
chance number=1
enter first digit for arbitary subtraction number for 6
10
enter second digit for arbitary subtraction number for 6
4
correct answer:
Question number=3
chance number=1
enter first digit for arbitary subtraction number for 5
10
enter second digit for arbitary subtraction number for 5
5
correct answer:
Question number=4
chance number=1
enter first digit for arbitary subtraction number for 3
10
enter second digit for arbitary subtraction number for 3
7
correct answer:
Question number=5
chance number=1
enter first digit for arbitary subtraction number for 5
10
enter second digit for arbitary subtraction number for 5
5
correct answer:
your score is 15:you successful crossed level 3:
CONGTATULATIONS YOU WON THE GAME:
Thank you:

fail in level 1:output

IN LEVEL 1:
Test in Addition and Subtraction
student enters level2 if scores 5 in level 1
Question number=1
chance number=1
what is subtraction of 8 and 4
2
wrong answer:
chance number=2
what is subtraction of 8 and 4
1
wrong answer:
Question number=2
chance number=1
what is subtraction of 8 and 6
2
correct answer:
Question number=3
chance number=1
what is subtraction of 6 and 0
4
wrong answer:
chance number=2
what is subtraction of 6 and 0
2
wrong answer:
Question number=4
chance number=1
what is addition of 7 and 6
1
wrong answer:
chance number=2
what is addition of 7 and 6
4
wrong answer:
Question number=5
chance number=1
what is addition of 5 and 5
2
wrong answer:
chance number=2
what is addition of 5 and 5
1
wrong answer:
Question number=6
chance number=1
what is subtraction of 9 and 0
5
wrong answer:
chance number=2
what is subtraction of 9 and 0
3
wrong answer:
Question number=7
chance number=1
what is subtraction of 6 and 5
5
wrong answer:
chance number=2
what is subtraction of 6 and 5
4
wrong answer:
Question number=8
chance number=1
what is subtraction of 2 and 1
3
wrong answer:
chance number=2
what is subtraction of 2 and 1
1
correct answer:
Question number=9
chance number=1
what is subtraction of 6 and 6
5
wrong answer:
chance number=2
what is subtraction of 6 and 6
3
wrong answer:
Question number=10
chance number=1
what is subtraction of 2 and 2
2
wrong answer:
chance number=2
what is subtraction of 2 and 2
5
wrong answer:
question over:
totalscore=2
GAME OVER!!!!!!!!!
please try level 1 again:
please start game again:
try again:

fail in level2 :output:

IN LEVEL 1:
Test in Addition and Subtraction
student enters level2 if scores 5 in level 1
Question number=1
chance number=1
what is addition of 5 and 3
8
correct answer:
Question number=2
chance number=1
what is subtraction of 5 and 2
3
correct answer:
Question number=3
chance number=1
what is addition of 7 and 1
8
correct answer:
Question number=4
chance number=1
what is subtraction of 6 and 3
4
wrong answer:
chance number=2
what is subtraction of 6 and 3
4
wrong answer:
Question number=5
chance number=1
what is addition of 5 and 1
6
correct answer:
Question number=6
chance number=1
what is addition of 7 and 3
10
correct answer:
your score is 5:you successful crossed level 1:
IN LEVEL 2:
Test in Arbitary single digit addition:
student enters level 3 if scores 5 in level 2
Question number=1
chance number=1
enter first digit for arbitary addition number for 9
4
enter second digit for arbitary addition number for 9
3
wrong answer:
chance number=2
enter first digit for arbitary addition number for 9
4
enter second digit for arbitary addition number for 9
2
wrong answer:
Question number=2
chance number=1
enter first digit for arbitary addition number for 7
4
enter second digit for arbitary addition number for 7
1
wrong answer:
chance number=2
enter first digit for arbitary addition number for 7
6
enter second digit for arbitary addition number for 7
23
wrong answer:
Question number=3
chance number=1
enter first digit for arbitary addition number for 7
23
enter second digit for arbitary addition number for 7
22
wrong answer:
chance number=2
enter first digit for arbitary addition number for 7
1
enter second digit for arbitary addition number for 7
0
wrong answer:
Question number=4
chance number=1
enter first digit for arbitary addition number for 7
4
enter second digit for arbitary addition number for 7
1
wrong answer:
chance number=2
enter first digit for arbitary addition number for 7
3
enter second digit for arbitary addition number for 7
2
wrong answer:
Question number=5
chance number=1
enter first digit for arbitary addition number for 1
54
enter second digit for arbitary addition number for 1
1
wrong answer:
chance number=2
enter first digit for arbitary addition number for 1
2
enter second digit for arbitary addition number for 1
1
wrong answer:
Question number=6
chance number=1
enter first digit for arbitary addition number for 8
3
enter second digit for arbitary addition number for 8
1
wrong answer:
chance number=2
enter first digit for arbitary addition number for 8
3
enter second digit for arbitary addition number for 8
1
wrong answer:
Question number=7
chance number=1
enter first digit for arbitary addition number for 7
3
enter second digit for arbitary addition number for 7
1
wrong answer:
chance number=2
enter first digit for arbitary addition number for 7
5
enter second digit for arbitary addition number for 7
1
wrong answer:
Question number=8
chance number=1
enter first digit for arbitary addition number for 9
44
enter second digit for arbitary addition number for 9
12
wrong answer:
chance number=2
enter first digit for arbitary addition number for 9
53
enter second digit for arbitary addition number for 9
12
wrong answer:
Question number=9
chance number=1
enter first digit for arbitary addition number for 5
33
enter second digit for arbitary addition number for 5
12
wrong answer:
chance number=2
enter first digit for arbitary addition number for 5
32
enter second digit for arbitary addition number for 5
11
wrong answer:
Question number=10
chance number=1
enter first digit for arbitary addition number for 2
33
enter second digit for arbitary addition number for 2
12
wrong answer:
chance number=2
enter first digit for arbitary addition number for 2
3
enter second digit for arbitary addition number for 2
1
wrong answer:
question over:
totalscore=5
GAME OVER!!!!!!!!!
please start game again:
try again: