Q:

Write a Java program to calculate the modules of two numbers without using any inbuilt modulus operator

0

Write a Java program to calculate the modules of two numbers without using any inbuilt modulus operator


Sample Output:

Input the first number : 19                                            
Input the second number: 7                                             
5   

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;
 public class Exercise65 {
 public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        System.out.print("Input the first number : ");
        int a = in.nextInt();  
		System.out.print("Input the second number: ");
		int b = in.nextInt(); 
		int divided = a / b;
		int result = a - (divided * b);
		System.out.println(result); 
	}
 }

Sample Output:

Input the first number : 19                                            
Input the second number: 7                                             
5 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now