Edit: to the whole question please. This for a java lab, the book referenced in
ID: 3908477 • Letter: E
Question
Edit: to the whole question please.
This for a java lab, the book referenced in the question is, getting started with java 6th edition, I have been unable to obtain the book, if anyone can help me with this, I would be very grateful, thank you!
2. Using MathTutor.java on page 250 make the following changes a. Do a random selection on the operation to perform. You can do this by running a generator with only 4 numbers and using a switch to pick your operator. b. Keep count of right and wrong answers and display the running totals c. "Emcompass" program in a loop to continue the game.Explanation / Answer
I googled a lot to get a pdf copy of the book, but it seems that the book is not available onlline. Without MathTutor.java file, it becomes difficult for any expert to answer your question. But I understand your position, hence, for the tme being, I can provide you a sample code which covers all the requirements. Once you provide the MathTutor.java file, I can update my code too.
CODE
=================
import java.util.Random;
public class tester {
public static void main(String[] args) {
Random rand = new Random();
int right = 0, wrong = 0;
while(true) {
int operation = rand.nextInt(4);
switch(operation) {
case 0:
// do the first operation here
// if answer is correct, then do right ++
// else do wrong ++;
System.out.println("Right answers = " + right + ", wrong answers = " + wrong);
break;
case 1:
// do the second operation here
// if answer is correct, then do right ++
// else do wrong ++;
System.out.println("Right answers = " + right + ", wrong answers = " + wrong);
break;
case 2:
// do the third operation here
// if answer is correct, then do right ++
// else do wrong ++;
System.out.println("Right answers = " + right + ", wrong answers = " + wrong);
break;
case 3:
// do the fourth operation here
// if answer is correct, then do right ++
// else do wrong ++;
System.out.println("Right answers = " + right + ", wrong answers = " + wrong);
break;
default:
System.out.println("Wrong input!!");
break;
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.