twitter
Showing posts with label Java Programming. Show all posts
Showing posts with label Java Programming. Show all posts

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...

Friday, October 28, 2011

Java Programming Chapter 6 (If Statement with Constructor)

Chapter 6 If statement with constructor in this chapter we will meet source code IF Statement with Constructor, check this code :
public class IfCabang { double angka; public IfCabang(){ } public IfCabang(double angka) { this.angka = angka; } public void setAngka(int angka) { this.angka=angka; }

Java Programming Chapter 5 (If Statement)

In this chapter I will explain about If statement, OK check this code :
The if statement has this form, where condition is true or false.
... // Do these statements before. if (condition) { ... // Do this clause if the condition is true. } ... // Do these statements after.

or
... // Do these statements before. if (condition) { ... // Do this clause if the condition is true } else { ... // Do this clause if the condition is false } ... // Do these statements after.

Monday, October 24, 2011

Java Programming Chapter 4 (Bigger Number)

Ok in this chapter i will share how to find the bigger number with use Java Input Output Buffered Reader check this code :
import java.io.*;
public class BiggerNum{
 public static void main(String[] args){
  BufferedReader inputnum = new BufferedReader(new InputStreamReader(System.in));
  String i="";
  int temp=0;
  for(int j=1; j<=3; j++){
   System.out.print("Input to"+j+" : ");
   try {
    i = inputnum.readLine();
   }catch(IOException e){
    System.out.println("data error!!!");
   }
   int input= Integer.parseInt(i);
  if (temp<input){
   temp=input;
   } 
  }
  
  System.out.println("Bigger number is : "+temp);
 }
}

Java Programming Chapter 3 (Display Variable)

Ok in this chapter I will share how to display variable
 
    public class DisplayVar {
    public static void main(String[] args) {
        int number = 10;
        char letter = 'a';
        boolean result = true;
        String str = "hello";
        System.out.println("Number = " +number);
        System.out.println("letter = " +letter);
        System.out.println("result = " +result);
        System.out.println("str = " +str);
    }
}

Java Programming Chapter 2 (The Tree)

Ok in this chapter we will show words in 4 line. Check this Code: 

public class TheTree {
 public static void main(String[] args) {
  System.out.println("I thinnk that I shall never see,");
  System.out.println("a poem as lovely as a tree.");
  System.out.println("A tree whose hungry mouth is pressed");
  System.out.println("Againts the Earth's sweet flowings breast.");
 }
}

Java Programming Chapter 1 (Hello World)

Ok now I will share to you how to make programm with Java Programming Language. In the first step you must now how to show the text, ok this is simple programm with Java, this program will show Hello World for the Out Put. Check this source code :


 public class Hello {
 public static void main(String[] args){
    System.out.print("Hello World");
 }
 }