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

  • برمجة جافا
  • برمجة

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   

الأجوبة

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 
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...