I have a major project that i need a good grade on... here's the project and following is my code.
My problem is that I am unable to make it try the question 3 times if it is answered wrong, and that i don't understand how to track the percent answered correctly. If you want to help on extra credit that would be awesome, but i'm mainly worried about the main project.
Thanks,
Brandon
You have been hired by Easy Street High School to write a basic computer-assisted instruction math drill program to help elementary students to learn basic math skills. Your program should meet the following specifications:
Write a MathDrill Class to implement the following tasks. The program that will print the following output and wait for the user to select the drills.
Easy CAI Math Drills
1. Addition
2. Subtraction
3. Multiplication
4. Division
Please select the drill you want to take, or Q to quit:
Ask 10 questions of the math drill questions based on the user preference. Use Random class to generate two integers between 0 to 9. For example, if the user chooses 3, you program should then display a question like the following: (Here boldface is what the user enter as input to the program.)
Problem 1 of 10
8 * 9 = 72
If the user answers correctly, choose randomly from one of the following responses and output it.
Very good!
Excellent!
Nice work!
Keep up the good work!
If the user answers incorrectly, choose randomly from one of the following responses and output it.
No. Please try again.
Wrong. Try once more.
Don't give up!
No. Keep trying.
Allow the student three chances to get the problem correct. If the student did not answer correctly 3 times for the same question, print the message "Incorrect Solution", and prints the correct solution for the problem. Here is a sample interactive session with the program you are to write. (Here boldface is what the user enter as input to the program.)
Easy CAI Math Drills
1. Addition
2. Subtraction
3. Multiplication
4. Division
Please select the drill you want to take, or Q to quit: 3
Problem 1 of 10
8 * 9 = 61
No. Keep trying.
8 * 9 = 89
Wrong. Try once more.
8 * 9 = 90
Incorrect Solution
Solution is: 8 * 9 = 72
Problem 2 of 10
6 * 4 = 24
Nice work!
Problem 3 of 10
8 * 6 = 48
Excellent!
.
.
.
After the student answers 10 questions, your program should calculate the number of correct responses and the percentage of correct responses and output both of them. If the percentage is lower than 75 percent, print Please ask your instructor for extra help. Then, display the Math Drill menu again.
You need to take care of the divide by 0 error. If the random generated denominator is 0, your program will regenerate a non zero denominator. You will need to set up a loop for it.
Extra Credits 1(10 points):
Modify the program to allow the user to pick number 5 from the menu which means a random mixture of problems of all four types math drill.
Extra Credits 2(10 points):
Modify the program to allow the user to enter a school grade-level capability. A grade level of 1 means that the program should use only single-digit numbers in the problems, a grade level of 2 means that the program should use numbers as large as two digits, and a grade level of 3 means that the program shuld use numbers as large as three digits.
Extra Credits 3(10 points):
Modify the program to use double/floating point instead of integer. The student's answer is considered to be correct by rounding up to the nearest hundredth.
Programming Style requirement: You should use OOP design as much as possible. Comment your program thoroughly using javadoc style comment. Use javadoc to create the html files. Please keep proper indentation.
import java.util.Scanner; import java.util.Random; public class MathDrill { public void doOperation (int choice) { Random rand1=new Random(); //to store first random number on it Random rand2=new Random(); //second random number // Random ex = new Random(); int input=0; //store user answer for question Scanner scan= new Scanner(System.in); //scan user input String [] correct = {"Very Good","Excellent","Nice Work !","Keep up the good work"}; String [] wrong = {"No. Please try again.","Wrong. Try once more.","Don't give up!","No. Keep trying."}; for (int i=1;i<11;i++) { int num1 = rand1.nextInt(11); //here we create a new random number using Math.random function it creates a random number between 0-->1 so we have to multiply by 10 and convert to integer to remove the part after the floating point int num2 = rand2.nextInt(11); // here we create second random number int x = (int) (Math.random() * 10); //this random number is for correct or wrong random statement stores in the arrays of strings while (x>3) //to not to exceed array of strings depth. { x = (int) (Math.random() * 10); } int result=0; //here we will store result4 of operation later System.out.println("Question "+i +" of 10"); //print out question number if (choice==1) { result=num1+num2; //the real result System.out.println(num1+" + "+num2 + " = "); //showing question to user input = scan.nextInt(); //scan user answer if (input!=result) { System.out.println(wrong[x]); } else { System.out.println(correct[x]); } } //here we repeat the same pattern for other operations. else if (choice==2) { result=num1-num2; System.out.println(num1+" - "+num2 + " = "); input = scan.nextInt(); if (input!=result) { System.out.println(wrong[x]); } else { System.out.println(correct[x]); } } else if (choice==3) { result=num1*num2; System.out.println(num1+" * "+num2 + " = "); input = scan.nextInt(); if (input!=result) { System.out.println(wrong[x]); } else { System.out.println(correct[x]); } } else if (choice==4) { if(num2!=0) { result=num1/num2; } System.out.println(num1+" / "+num2 + " = "); input = scan.nextInt(); if (input!=result) { System.out.println(wrong[x]); } else { System.out.println(correct[x]); } } } } // public void getPercent{ // int count; }