Sunday, October 23, 2011

Finding quotient and remainder of two numbers (Java)

//This Java program accepts two numbers
//from the user and then  prints the quotient
//obtained by dividing the first number by the
//second and also prints the remainder.
import java.util.*;
class remainderAndQuotient
{
static void main()
{
int n,q,a,k=1,r;
Scanner sc=new Scanner(System.in);
System.out.println("Enter 2 numbers");
n=sc.nextInt();
a=sc.nextInt();
r=n%a;
q=n/a;
System.out.println("Quotient : "+q);
System.out.println("Remainder : "+r);
}
}
//Author : Mayank Rajoria

No comments:

Post a Comment