belajar java part 3 pertemuan 7

import java.util.Scanner;
class Korelasi
{
Scanner input = new Scanner(System.in);
double[] x;
double[] y;
double[] x2;
double[] y2;
double[] xy;
int n;

public Korelasi()
{
menu();
}
public void menu()
{
System.out.println(“——————“);
System.out.println(“| Menu Utama |”);
System.out.println(“|—————-|”);
System.out.println(“| 1. Input |”);
System.out.println(“| 2. Korelasi |”);
System.out.println(“| 3. Exit |”);
System.out.println(“|—————-|”);
System.out.print(“Masukkan Pilihan Kamu : ” );
int pil = input.nextInt();
switch(pil)
{
case 1:
try{
input();
}catch(IndexOutOfBoundsException ex){
System.out.println(“Ada Kesalahan pada proses IO”);
}
menu();
case 2:
hitungKorelasi();
menu();

case 3:
System.out.println(“tengkyuuuu …… !=D”);
System.exit(0);

default:
System.exit(0);
}
}

public void input()
{
System.out.print(“masukkan banyaknya data :”);
n = input.nextInt();
x= new double[n];
y= new double[n];
x2 = new double[n];
y2=new double[n];
xy=new double[n];

System.out.print(“\nmasukkan data x :\n”);
for(int i=0;i<n;i++)
{
System.out.print("data ke-"+(i+1)+":");
x[i]= input.nextDouble();
}

System.out.println("\nmasukkan data y :");
for(int i=0;i<n;i++)
{
System.out.print("data ke-"+(i+1)+":");
y[i]= input.nextDouble();
}

for(int i=0 ; i<n;i++)
{
x2[i]= Math.pow(x[i],2);
y2[i]= Math.pow(y[i],2);
xy[i]= x[i] * y[i] ;

}
}

public double sigma(double k[])
{
double data = 0;
for(int i=0; i 0 ){
System.out.println(“hubungan dua variabel adalah paralel”);
} else if(hasil<0){
System.out.println("hubungan dua variabel bertolak belakang");
} else {
System.out.println("tidak ada hubungan linier antara dua variabel");
}
}
public static void main(String[] args)
{
new Korelasi();
}
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s