Minggu, 09 Desember 2012

Grade


import java.text.*;
import java.util.Scanner;

public class grade
{
double HitungAbsen(double a){
return 0.1*a;
}
double HitungTugas(double b){
return  0.2*b;
}
double HitungUTS(double c){
return  0.3*c;
}
double HitungUAS(double d){
return  0.4*d;
}
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
System.out.println();
System.out.print ("Masukkan Nilai Absen= ");
double e=input.nextDouble();
System.out.print ("Masukkan Nilai Tugas= ");
double f=input.nextDouble();
System.out.print ("Masukkan Nilai UTS= ");
double g=input.nextDouble();
System.out.print ("Masukkan Nilai UAS= ");
double h=input.nextDouble();

grade m=new grade();
NumberFormat n=new DecimalFormat("#,##");

double t=m.HitungAbsen(e)+m.HitungTugas(f)+m.HitungUAS(g)+m.HitungUTS(h);
String k="";

if (t>=9)
k="Grade A";
else if(t>=8)
k="Grade B";
else if(t>=7)
k="Grade c";
else if(t>=6)
k="Grade D";
else
k="Grade E";


System.out.println ("Nilai Akhir Anda adalah "+t);
System.out.println ("Nilai Akhir Anda Format Desimal adalah "+n.format(t));
System.out.println ("Grade Anda adalah "+k);
return;
}
}


Mencari Nilai Akar di Java


import java.text.*;
import java.util.Scanner;

public class akar
{
double Hitungakar(double i){
return  Math.sqrt(i);
}
public static void main(String args[])
{
akar a=new akar();
NumberFormat h=new DecimalFormat("#,##");
Scanner input = new Scanner(System.in);
System.out.print ("Masukkan Angka = ");
int c=input.nextInt();

System.out.println ("Nilai akar asli adalah "+a.Hitungakar(c));
System.out.println ("Nilai akar format decimal adalah "+h.format(a.Hitungakar(c)));
}
}