PROGRAM ARRAY IP MAHASISWA BAHASA JAVA
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;
public class yogipratama
{
public static void main(String[]args)
{
Scanner masuk=new Scanner(System.in);
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
int p;
String []nim=new String[10];
String []nama=new String[10];
String []alamat=new String[10];
String []nh=new String[10];
int[]nilaiuts = new int[10];
int[]nilaiuas = new int[10];
int[]nilaitotal = new int[10];
int []semester=new int[10];
int []nilaitgs=new int[10];
int n;
System.out.print("Berapa banyak data : ");
n=masuk.nextInt();
for(p=0;p<n;p++)
{
System.out.print("input nim ke-"+(p+1)+" : ");
try
{
nim [p]=dataIn.readLine();
}
catch(IOException e)
{
System.out.println("error!");
}
System.out.print("input nama ke-"+(p+1)+" : ");
try
{
nama [p]=dataIn.readLine();
}
catch(IOException e)
{
System.out.println("error!");
}
System.out.print("input alamat ke-"+(p+1)+" : ");
try
{
alamat [p]=dataIn.readLine();
}
catch(IOException e)
{
System.out.println("error!");
}
System.out.print("input semester ke-"+(p+1)+" : ");
{
semester[p]=masuk.nextInt();
}
System.out.print("input nilai uas ke-"+(p+1)+" : ");
nilaiuas [p]=masuk.nextInt();
System.out.print("input nilai uts ke-"+(p+1)+" : ");
nilaiuts [p]=masuk.nextInt();
System.out.print("input nilai tgs ke-"+(p+1)+" : ");
nilaitgs [p]=masuk.nextInt();
nilaitotal[p]=((nilaitgs[p]+nilaiuts[p]+nilaiuas[p])/3);
System.out.print("\n");
if(nilaitotal[p]>=80)
nh[p]="A";
else if(nilaitotal[p]>=70)
nh[p]="B";
else if(nilaitotal[p]>=60)
nh[p]="C";
else if(nilaitotal[p]>=50)
nh[p]="D";
else
nh[p]="E";
}
System.out.print("\n\n");
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("| nim | nama | alamat | semester | nilaitgs | nilaiuas | nilaiuts | nilai total| nilaihuruf|");
for(p=0;p<n;p++)
{
System.out.print("|"+" "+nim[p]+"|");
System.out.print(" "+nama[p]+"|");
System.out.print(" "+alamat[p]+"|");
System.out.print(" "+semester[p]+"|");
System.out.print(" "+nilaitgs[p]+"|");
System.out.print(" "+nilaiuas[p]+"|");
System.out.print(" "+nilaiuts[p]+"|");
System.out.print(" "+nilaitotal[p]+"|");
System.out.print(" "+nh[p]+"|");
System.out.print("\n");
}
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
}
import java.util.Scanner;
public class yogipratama
{
public static void main(String[]args)
{
Scanner masuk=new Scanner(System.in);
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
int p;
String []nim=new String[10];
String []nama=new String[10];
String []alamat=new String[10];
String []nh=new String[10];
int[]nilaiuts = new int[10];
int[]nilaiuas = new int[10];
int[]nilaitotal = new int[10];
int []semester=new int[10];
int []nilaitgs=new int[10];
int n;
System.out.print("Berapa banyak data : ");
n=masuk.nextInt();
for(p=0;p<n;p++)
{
System.out.print("input nim ke-"+(p+1)+" : ");
try
{
nim [p]=dataIn.readLine();
}
catch(IOException e)
{
System.out.println("error!");
}
System.out.print("input nama ke-"+(p+1)+" : ");
try
{
nama [p]=dataIn.readLine();
}
catch(IOException e)
{
System.out.println("error!");
}
System.out.print("input alamat ke-"+(p+1)+" : ");
try
{
alamat [p]=dataIn.readLine();
}
catch(IOException e)
{
System.out.println("error!");
}
System.out.print("input semester ke-"+(p+1)+" : ");
{
semester[p]=masuk.nextInt();
}
System.out.print("input nilai uas ke-"+(p+1)+" : ");
nilaiuas [p]=masuk.nextInt();
System.out.print("input nilai uts ke-"+(p+1)+" : ");
nilaiuts [p]=masuk.nextInt();
System.out.print("input nilai tgs ke-"+(p+1)+" : ");
nilaitgs [p]=masuk.nextInt();
nilaitotal[p]=((nilaitgs[p]+nilaiuts[p]+nilaiuas[p])/3);
System.out.print("\n");
if(nilaitotal[p]>=80)
nh[p]="A";
else if(nilaitotal[p]>=70)
nh[p]="B";
else if(nilaitotal[p]>=60)
nh[p]="C";
else if(nilaitotal[p]>=50)
nh[p]="D";
else
nh[p]="E";
}
System.out.print("\n\n");
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("| nim | nama | alamat | semester | nilaitgs | nilaiuas | nilaiuts | nilai total| nilaihuruf|");
for(p=0;p<n;p++)
{
System.out.print("|"+" "+nim[p]+"|");
System.out.print(" "+nama[p]+"|");
System.out.print(" "+alamat[p]+"|");
System.out.print(" "+semester[p]+"|");
System.out.print(" "+nilaitgs[p]+"|");
System.out.print(" "+nilaiuas[p]+"|");
System.out.print(" "+nilaiuts[p]+"|");
System.out.print(" "+nilaitotal[p]+"|");
System.out.print(" "+nh[p]+"|");
System.out.print("\n");
}
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
}
Tidak ada komentar:
Posting Komentar