Program Pada Class Konversi Nilai
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Nilai;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author awan
*/
public class konversinilai {
int x,y;
String name[]=new String [10];
int nilai1 []=new int [10];
int nilai2[]=new int [10];
int nilaiakhir[]=new int[10];
String pil;
void nilaiakhir()throws IOException{
BufferedReader input=new BufferedReader (new InputStreamReader(System.in));
do{
System.out.print("NAMA : ");
name[x]=(input.readLine());
System.out.print("Nilai 1 :");
nilai1[x]=Integer.parseInt(input.readLine());
System.out.print("Nilai 2 :");
nilai2[x]=Integer.parseInt(input.readLine());
nilaiakhir[x]=(nilai1[x]+nilai2[x])/2;
System.out.print("Input Data Lagi[y/t]:");
pil=(input.readLine());
if ((pil.compareTo("Y")==0)||(pil.compareTo("y")==0))
{
x+=1;
}
}while ((pil.compareTo("Y")==0)||(pil.compareTo("y")==0));
}
void cetak (){
{
System.out.println("---------------------------------------");
System.out.println("Nama | Nilai 1 | Nilai 2 |Nilai Akhir |");
System.out.println("---------------------------------------");
for(y=0;y<=x;y++)
System.out.println(" "+name[y]+" " +nilai1[y]+" "+nilai2[y]+" "+nilaiakhir[y]);
}
}
}
Program Untuk Menjalankan Pada ClassLakukan
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Nilai;
import java.io.IOException;
/**
*
* @author awan
*/
public class lakukan {
public static void main (String[] args) throws IOException {
// TODO code application logic here
konversinilai k=new konversinilai();
k.nilaiakhir();
k.cetak();
}
}
![]() |
Tidak ada komentar:
Posting Komentar