/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/DivisionQuiz.java |
package com.calebfontenot.lab7_calebfontenot;
import java.util.Scanner;
@author
public class DivisionQuiz {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int number1,
number2,
answerQuotient,
answerRemainder;
boolean cheatMode = false;
while (true) {
number1 = (int) (Math.random() * 100);
number2 = (int) (Math.random() * 100);
if (number1 < number2) {
int tmp = number2;
number2 = number1;
number1 = tmp;
}
if (cheatMode == true) {
System.out.println("CHEAT MODE: the quotient of " + number1 + " / " + number2 + " is " + (number1 / number2));
}
System.out.print(" What is the quotient of " + number1 + " / " + number2 + "? ");
answerQuotient = input.nextInt();
if (cheatMode == true) {
System.out.println("CHEAT MODE: the remainder of " + number1 + " % " + number2 + " is " + (number1 % number2));
}
System.out.print(" What is the remainder of " + number1 + " / " + number2 + "? ");
answerRemainder = input.nextInt();
if ((number1 / number2) == answerQuotient)
{
System.out.println("You are correct about the quotient!");
} else {
System.out.println("You are wrong about the quotient.");
System.out.println("The quotient of " + number1 + " / " + number2 + " is " + (number1 / number2));
}
if ((number1 % number2) == answerRemainder)
{
System.out.println("You are correct about the remainder!");
} else {
System.out.println("You are wrong about the remainder.");
System.out.println("The remainder of " + number1 + " % " + number2 + " is " + (number1 % number2));
}
}
}
}