Division Solution


import java.util.Scanner;
/*
Write a Java Program that: 1- Prompts for two positive Integer inputs
(numerrator, denominator) from user 2- Displays Quotient and Remainder
of above two inputs 3- Prompts user to type a negative number to exit
and any other number to continue
*/
public class Divison {
public static void main(String[] args) {
int numerator, denominator;
int Quotient, Remainder;
int again = 0;
Scanner sc = new Scanner (System.in);
do
{
System.out.print("Enter numerator: ");
numerator = sc.nextInt();
System.out.print("Enter denominator: ");
denominator = sc.nextInt();

//calculate Quotient and Remainder
Quotient = numerator / denominator;
Remainder = numerator % denominator;

//display result
System.out.println("Quotient = " + Quotient);
System.out.println("Remainder = " + Remainder);

//ask user to continue
System.out.println("Enter negative number to end, positive to continue: ");
again = sc.nextInt();
}while(again = 0);
}
}
Powered by