46 lines
1.4 KiB
Java
Executable File
46 lines
1.4 KiB
Java
Executable File
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
package programmingexam1_calebfontenot;
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
/**
|
|
*
|
|
* @author ar114
|
|
*/
|
|
public class QuotientAndRemainderOfNumbersInAnyOrder {
|
|
public static void main(String[] args) {
|
|
// Define variables
|
|
int number1, number2, quotient, remainder;
|
|
|
|
// Create scanner
|
|
Scanner input = new Scanner(System.in);
|
|
|
|
// Prompt for variables
|
|
System.out.print("Enter 2 variables and I will calculate the "
|
|
+ "quotient and the remainder: ");
|
|
number1 = input.nextInt();
|
|
number2 = input.nextInt();
|
|
|
|
// Compute!
|
|
if (number1 <= number2) {
|
|
System.out.println(number1 + " < " + number2 + "!");
|
|
int tmp = number2; // temp variable to store the number
|
|
number2 = number1;
|
|
number1 = tmp;
|
|
}
|
|
|
|
quotient = number1 / number2;
|
|
remainder = number1 % number2;
|
|
|
|
// Print output:
|
|
System.out.println(number1 + " / " + number2 + " =");
|
|
System.out.println("The quotient is: " + quotient);
|
|
System.out.println("The remainder is: " + remainder);
|
|
}
|
|
}
|