0

Write a java program that read 2 integers numbers, Then determines and prints if the first is a multiple(double) of the second

NOTE : Using if and else statements - and use the modulus ( the percentage mark ) to answer the question

this is my answer !!

pllz if any one found any mistake just tell me

package project1;
 
import javax.swing.JOptionPane;

public class Class1 {

public static void main (String args[] ){
    
    int num1,num2;
    
    num1=Integer.paresInt(JOptionPane.ShowMessageDialog("is number1 double num2?"));
    num2=Integer.paresInt(JOptionPane.ShowMessageDialog("is number2 double num1?"));

//What can i write inside the IF brackets bellow ??
if(num1%){
    
}
System.out.println(YES);

else

System.out.println(NO);


}

}

and thanq

btw im so bad in English
Please do not focus too much :s :p
hehehehehe

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pbl
0

The % returns the modulo (reminder) of first number divided by second number so

5 % 2 is 1
and 6 % 3 is 0

so if(num1 % num2 == 0) it means that num1 is an excat multiple od num2

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.