Selasa, 09 Oktober 2012

PROGRAM MENENTUKAN KUADRAN KOORDINAT SUATU TITIK (netbeans)

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package postest2;

/**
 *
 * @author JustVicky
 */
public class Titik {
    private String x;
    private String y;
    
    public Titik(){}
    public Titik(String x, String y){
        this.x = x;
        this.y = y;
        
    }
    
    
    public void setX(String x){
        this.x = x;
    }
    
    public String getX(){
        return x;
    }
    
    public void setY(String y){
        this.y = y;
    }
    
    public String getY(){
        return y;
    }
}

===================================

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package postes2;

/**
 *
 * @author JustVikcy
 */
import java.util.Scanner;
public class Postes2 {

    public static void main (String [] args){
       
        Scanner input = new Scanner(System.in);
       
        System.out.print("Masukkan Posisi X : ");
        int x = input.nextInt();
       
        System.out.print("Masukkan Posisi y : ");
        int y = input.nextInt();
       
        if(x>0&&y>0)
            System.out.println("Titik x = "+x+" and y = "+y+"K 1");
        else if(x<0&&y>0)
            System.out.println("Titik x = "+x+" and y = "+y+"K 2");
        else if(x<0&&y<0)
            System.out.println("Titik x = "+x+" and y = "+y+"K 3");
        else
            System.out.println("Titik x = "+x+" and y = "+y+"K 4");
           
        double jarak = Math.sqrt((x*x)+(y*y));
          System.out.println("Jarak dari titik = "+jarak);
    }
}

1 komentar: