Mencari sistem koordinat dengan java



//mencari koordinat kartesius
import javax.swing.JOptionPane;
public class sistemKoordinat
{
 public static void main(String [] args)
 {
 JOptionPane.showMessageDialog(null, "Mencari Posisi sebuah titik P(X,Y)","SISTEM KOORDINAT KERTESIUS", JOptionPane.INFORMATION_MESSAGE);
 //pengulangan
 do
 {
 //input nilai
 String X = JOptionPane.showInputDialog("Masukkan nilai titik X");
 String Y = JOptionPane.showInputDialog("Masukkan nilai titik Y");
 //konversi
 int a = Integer.parseInt(X);
 int b = Integer.parseInt(Y);
 //kondisi
 if ((a == 0) && (b == 0))
 {
 JOptionPane.showMessageDialog(null, "Titik P("+X+","+Y+") Adalah titik asal","SISTEM KOORDINAT KERTESIUS", JOptionPane.INFORMATION_MESSAGE);
 }
 else
 if ((a > 0) && (b > 0))
 {
 JOptionPane.showMessageDialog(null, "Titik P("+X+","+Y+") Berada di Kuadran I","SISTEM KOORDINAT KERTESIUS", JOptionPane.INFORMATION_MESSAGE);
 }
 else
 if ((a < 0) && (b > 0))
 {
 JOptionPane.showMessageDialog(null, "Titik P("+X+","+Y+") Berada di Kuadran II","SISTEM KOORDINAT KERTESIUS", JOptionPane.INFORMATION_MESSAGE);
 }
 else
 if ((a < 0) && (b < 0))
 {
 JOptionPane.showMessageDialog(null, "Titik P("+X+","+Y+") Berada di Kuadran III","SISTEM KOORDINAT KERTESIUS", JOptionPane.INFORMATION_MESSAGE);
 }
 else
 if ((a > 0) && (b < 0))
 {
 JOptionPane.showMessageDialog(null, "Titik P("+X+","+Y+") Berada di Kuadran IV","SISTEM KOORDINAT KERTESIUS", JOptionPane.INFORMATION_MESSAGE);
 }
 if ((a == 0) && (b > 0))
 {
 JOptionPane.showMessageDialog(null,"ERROR","SISTEM KOORDINAT KERTESIUS", JOptionPane.ERROR_MESSAGE);
 }
 else
 if ((a == 0) && (b < 0))
 {
 JOptionPane.showMessageDialog(null,"ERROR","SISTEM KOORDINAT KERTESIUS", JOptionPane.ERROR_MESSAGE);
 }
 else
 if ((a < 0) && (b == 0))
 {
 JOptionPane.showMessageDialog(null,"ERROR","SISTEM KOORDINAT KERTESIUS", JOptionPane.ERROR_MESSAGE);
 }
 else
 if ((a > 0) && (b == 0))
 {
 JOptionPane.showMessageDialog(null,"ERROR","SISTEM KOORDINAT KERTESIUS", JOptionPane.ERROR_MESSAGE);
 }
 }
 while (JOptionPane.showConfirmDialog(null, "Ulangi program") == JOptionPane.YES_OPTION);
 }
}



Post a Comment

0 Comments