Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Test {
- public static void main(String[] args) {
- /*Scanner x=new Scanner(System.in);
- System.out.println("Masukan Input : ");
- int a;
- a=x.nextInt();
- int b=a;
- for(int i=0;b>-1;i++){
- if(i<=b)
- System.out.print(" ");
- else if(i<=a)
- System.out.print("*");
- else{
- System.out.println();
- b--;
- i=0;
- }
- }
- */
- Scanner x=new Scanner(System.in);
- int pilih=0;
- String[] id;
- String[] nama;
- int[] nilai;
- int jumlah=0;
- id=new String[5];
- nama=new String[5];
- nilai=new int[5];
- do{
- for(int i=0;i<25;i++)
- System.out.println("");
- System.out.println("1. Input Student");
- System.out.println("2. See All Data");
- System.out.println("3. Edit Data");
- System.out.println("4. Exit");
- System.out.print("Masukan Input : ");
- pilih=x.nextInt();
- switch(pilih){
- case 1:
- do{
- System.out.print("How many student [1..5] :");
- jumlah=x.nextInt();
- }while(jumlah<1||jumlah>5);
- for(int i=0;i<jumlah;i++){
- do{
- System.out.print("Please Input User ID[10] : ");
- id[i]=x.next();
- }while(id[i].length()!=10);
- do{
- System.out.print("Please Input User Name : ");
- nama[i]=x.next();
- }while(nama[i].equals(" "));
- do{
- System.out.print("Please Input User Score : ");
- nilai[i]=x.nextInt();
- }while(nilai[i]>100||nilai[i]<0);
- System.out.println("");
- }
- break;
- case 2:
- if(jumlah==0)
- System.out.println("Data Tidak ada.");
- else{
- System.out.println("There is already "+jumlah+" data");
- for(int i=0;i<jumlah;i++){
- System.out.println((i+1)+". "+nama[i]);
- }
- int a;
- do{
- System.out.print("Please Input Student Number [1..."+(jumlah)+"] : ");
- a=x.nextInt();
- }while(a>jumlah||a<0);
- System.out.println("Student With No. "+a+" is");
- System.out.println("Student ID : "+id[a-1]);
- System.out.println("Student Name : "+nama[a-1]);
- System.out.println("Mark : "+nilai[a-1]);
- }
- x.nextLine();
- x.nextLine();
- break;
- case 3:
- int a;
- if(jumlah==0)
- System.out.println("Data Tidak ada.");
- else{
- System.out.println("There is already "+jumlah+" data");
- for(int i=0;i<jumlah;i++){
- System.out.println((i+1)+". "+nama[i]);
- }
- do{
- System.out.print("Please Input Student Number [1..."+(jumlah)+"] : ");
- a=x.nextInt();
- }while(a>jumlah||a<0);
- System.out.println("Student With No. "+a+" is");
- a--;
- System.out.println("Student ID : "+id[a]);
- System.out.println("Student Name : "+nama[a]);
- System.out.println("Mark : "+nilai[a]);
- do{
- System.out.print("Please Input Student ID[10] : ");
- id[a]=x.next();
- }while(id[a].length()!=10);
- do{
- System.out.print("Please Input Student Name : ");
- nama[a]=x.next();
- }while(nama[a].equals(" "));
- do{
- System.out.print("Please Input Student Score : ");
- nilai[a]=x.nextInt();
- }while(nilai[a]>100||nilai[a]<0);
- }
- System.out.println("");
- x.nextLine();
- x.nextLine();
- break;
- case 4:
- break;
- }
- }while(pilih!=4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment