/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package agnescantik;
/**
*
* @author agnes
*/
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 agnescantik;
/**
*
* @author agnes
*/
import java.util.Scanner;
public class agnescantik2 {
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);
}
}
semoga bermanfaat :)
0 komentar:
Post a Comment