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

AT&T; LTE @95%. 12:14 PM d21.lonestar.edu Math Tutor Due Feb 8, 2016 11.30 PM 0L

ID: 3665887 • Letter: A

Question

AT&T; LTE @95%. 12:14 PM d21.lonestar.edu Math Tutor Due Feb 8, 2016 11.30 PM 0Language COX-1320 2001 8W1 You are being contracted to create a math tutoring program for a local elementary school. This tutoring software should ask children which operation they would like to work on. Their choices should be as follows 1. Addition 2. Subtraction s. Multiplication 4 Quit Tutor If any of the first three is selected, the user should be presented with 10 RANDOM mathematical problems from that set one at a time. At all times the student should know what question in the set he/she is working on out of 10 questions. The user should also know how many attempts he/she has taken per question. If the user answers a problem incorrectly, the user should be notified that the response is incorrect and be given multiple chances to answer the question correctly. With each incorrect answer, the attempt count should increase. In the event of a correct response, the user should be notified that the answer is correct and the next problem should appear Upon completion of the question set, the user should be given a report of the number of questions answered correctly and in how many attempts. The user's grade should be calculated as (correctAnswers / NumberOfAttempts 100). The initial menu should be re-displayed and the user given the opportunity to attempt another set of random problems from the chosen operation Also, write the result of the student to a fle for output. This means you should ask for the student's name prior to the menu for operation exercises. The file output should have

Explanation / Answer

import java.util.Scanner;
import java.util.Random;
public class MathTutor
{
Scanner input = new Scanner(System.in);
int choice;
int numCorrect;
Random generator = new Random();
public MathTutor ()
{
choice = numCorrect = 0;
}
public int getQuestionType(){ while (choice < 1 || choice > 4)
{
System.out.println("Please select the type of questions you would like");
System.out.println("1) Addition");
System.out.println("2) Subtraction");
System.out.println("3) Multiplication");
System.out.println("4) Division");
System.out.print("Type: ");
choice = input.nextInt();
if (choice < 1 || choice > 4)
{
System.out.println("Choice must be in the range 1-4");
}
}
return choice;
}
public void askQuestions()
{
for (int i = 0; i < 10; i++)
{
int num1 = genRandomNum();
int num2 = genRandomNum();
int num3 = genRandomNum();
int sign = choice;
if (sign == 5)
{
sign = (int)(Math.random() * 4 + 1);
}
switch(sign)
{
case 1: addition(num1, num2);
break;
case 2: subtraction(num1, num2);
break;
case 3: multiplication(num1, num2);
break;
case 4: division(num1, num2, num3);
break;
default: System.out.println("Error");
System.exit(1);
}
}
}
public int genRandomNum()
{
return (int)generator.nextInt(9) +1;
}
public void genMotivationalPhrase()
{
int numMo = (int)generator.nextInt(4)+1;
switch(numMo)
{
case 1: System.out.println("Great job!");
break;
case 2: System.out.println("I knew you could do it!");
break;
case 3: System.out.println("Math is easy!");
break;
case 4: System.out.println("Hello MIT!");
break;
default: System.out.println("Error");
}
}
public void genMotivationalWrPhrase()
{
int numMo = (int)generator.nextInt(4)+1;
switch(numMo)
{
case 1: System.out.println("Try again!");
break;
case 2: System.out.println("So close!");
break;
case 3: System.out.println("I know you can do it!");
break;
case 4: System.out.println("You'll get it next time!");
break;
default: System.out.println("Error");
}
}
public void addition(int num1, int num2)
{
System.out.print("What is " + num1 + " + " + num2 + "? ");
int answer = input.nextInt();
if (num1 + num2 == answer)
{
genMotivationalPhrase();
numCorrect++;
}
else
{
genMotivationalWrPhrase();
}
}
public void subtraction(int num1, int num2)
{
if(num1>num2)
{
System.out.print("What is " + num1 + " - " + num2 + "? ");
int answer = input.nextInt();
if (num1 - num2 == answer)
{
genMotivationalPhrase();
numCorrect++;
}
else
{
genMotivationalWrPhrase();
}
}
else{
System.out.print("What is " + num2 + " - " + num1 + "? ");
int answer = input.nextInt();
if (num2 - num1 == answer)
{
genMotivationalPhrase();
numCorrect++;
}
else
{
genMotivationalWrPhrase();
}
}
}
public void multiplication(int num1, int num2)
{
System.out.print("What is " + num1 + " * " + num2 + "? ");
int answer = input.nextInt();
if (num1 * num2 == answer)
{
genMotivationalPhrase();
numCorrect++;
}
else
{
genMotivationalWrPhrase();
}
}
public void division(int num1, int num2, int num3)
{
boolean quotientCorrect = false;
num3 = num1*num2;
System.out.print("What is the quotient of " + num3 + " / " + num1 + "? ");
int answer = input.nextInt();
if (answer == num3/num1);
{
quotientCorrect = true;
}
if (quotientCorrect)
{
genMotivationalPhrase();
numCorrect++;
}
else
{
genMotivationalWrPhrase();
}
}
public void printReport()
{
double win = 10.0;
System.out.println("Number of correct responses: " + numCorrect + "/" + 10);
double percent = numCorrect / win * 100 ;
System.out.println("Your percentage: " + percent + "%");
if(percent<75){
System.out.println("Please see your teacher for help with ");
if(choice==1)
System.out.println("Addition");
else if(choice==2)
System.out.println("Subtraction");
else if(choice==3)
System.out.println("Multiplication");
else if(choice==4)
System.out.println("Division");}
}
}
public class MathTutorClient
{
public static void main(String args[])
{
MathTutor tutor = new MathTutor();
int choice = tutor.getQuestionType();
tutor.askQuestions();
tutor.printReport();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote