Praktikum 2 (Operasi Aritmatika )
*** MENGHITUNG RATA RATA
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Praktik2;
/**
*
* @author anik nurul
*/
public class Tugas1 {
public static void main(String[]args){
int a,b,c,d,e,f;
double x;
double y;
a=3;
b=4;
c=5;
d=6;
e=7;
f=9;
x=(a+b+c+d+e+f);
//rumus dari rata-rata adalah jumlah data : banyak data
y=x/6;
//System.out.println("" + x);
System.out.println("rata rata yang diperoleh = "+y);
}
}
*** MENGHITUNG AKAR PANGKAT
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Praktik2;
/**
*
* @author anik nurul
*/
public class Tugas2 {
public static void main (String[]args){
int a=3;
int b=4;
int c=5;
int d=6;
int e=7;
int f=9;
double x = Math.sqrt(b);//akar b
double y = Math.sqrt(f);//akar f
double z = Math.pow(a,3); //a pangkat 3
double Hasil = Math.sqrt(x +(y * c)+z); // akar dari akar b + akar f + c + a^3
System.out.println("Hasil =" +Hasil);
}
}
*** MENGHITUNG AKAR PANGKAT
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Praktik2;
/**
*
* @author anik nurul
*/
public class Tugas3 {
public static void main (String[]args){
int a=3;
int b=4;
int c=5;
int d=6;
int e=7;
int f=9;
double x = (Math.pow(c, 2))+f;
double y = (Math.pow(e,2)- Math.pow(b,2));
double Hasil = x-y;
System.out.println("Hasil = "+ Hasil);
}
}
*** MENGHITUNG MENIT JAM
/** To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Praktik2;
/**
*
* @author anik nurul
*/
public class Tugas4 {
public static void main(String[]args)
{
int x = 4 ;
int y = 30 ;
int jam = x * 3600;
int menit = y * 60;
int Hasil = jam + menit;
// double satu = 4;
// double dua = 4*3600;
//double tiga=30;
//double empat=30*60;
//double lima = dua + empat;
// System.out.println(satu+"jam"+tiga+"menit"+"jika dijadikan dalam detik adalah");
//System.out.println(lima+"detik");
System.out.println("4 jam = "+jam +" detik");
System.out.println("30 Menit = "+menit+" detik");
System.out.println("Hasil = " + Hasil);
}
}
Comments
Post a Comment