import java.io.*;
// javac simple_modulus.java
public class simple_modulus
{
public static void main(String args[])throws IOException
{
/*this is a comment
compile as
javac multi_comment.java
call as java simple_comment */
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.print("Type numbers only: ");
String str = "";
str = br.readLine();
System.out.println(str);
double d1 = Double.parseDouble(str);
System.out.println();
System.out.println(d1 += d1);
double n1 = d1 % 3 ;
System.out.println("d1 % 3 is " + n1);
double d2 = d1 / 3 ;
System.out.println("d1 / 3 is " + d2);

}
}

 

import java.io.*;

// javac only_modulus.java
public class only_modulus
{
public static void main(String args[])throws IOException
{
//note the use of buffer reader
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);

System.out.print("Type numbers only: ");
String str = "";
str = br.readLine();
if(str !="")
{
System.out.println(str);
double d1 = Double.parseDouble(str);
System.out.println("you entered : " + d1);
//for(int i = 0; i < 7 ; i++)
System.out.println("d1 % 2 = " + d1 % 2 + "\td1/2 = " + d1/2);
System.out.println("d1 % 3 is " + d1 % 3 + "\td1/3 = " + d1/3);
System.out.println("d1 % 4 is " + d1 % 4 + "\td1/4 = " + d1/4);
System.out.println("d1 % 5 is " + d1 % 5 + "\td1/5 = " + d1/5);
System.out.println("--Hadle above routine with for loop--");
}

}
}