twitter

Sunday, October 30, 2011

Java Programming Chapter 7 (Multiple Three)

Meet again in Java Programming with me Taufik R Firdaus. Ok in this time I will share to you, how to make program Multiple of Three. Check this code... :
import javax.swing.JOptionPane;
public class MultipleThree {
 public static void main(String[] main){
  int var1 = Integer.parseInt(JOptionPane.showInputDialog("Input end of number : "));
  for (int i=1; i <= var1; i++){
   if (i%3 ==0){
    System.out.println(i);
   }
  }
 }
}


  1. % sign it use for Mod (residual from divide)
  2. If state use for selection if value variable i mod 3 is 0 then show the number variable i

Ok see you agan in next chapter...

No comments:

Post a Comment