Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.96 KB | None | 0 0
  1. package sis;
  2.  
  3. import java.text.DecimalFormat;
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class Main {
  8.  
  9.     static Scanner console = new Scanner(System.in);
  10.     static Scanner consoleDouble = new Scanner(System.in);
  11.     static DecimalFormat numberFormat = new DecimalFormat("#.000");
  12.     public static void main(String[] args) throws InterruptedException {
  13.    
  14.         String loginUname;
  15.         String loginPword;
  16.         String[] uname = new String[1000];
  17.         String[] pword = new String[1000];
  18.         String[] name = new String[1000];
  19.         String[] bday = new String[1000];
  20.         String choice;
  21.         double computation;
  22.         double[][] subjects = new double[1000][5];
  23.         int x=0, y=0, z=0;
  24.         boolean login = false, exit = false;
  25.        
  26.         do{
  27.             do{
  28.                 System.out.printf("Do you want to [L]ogin or [S]ignup?: ");
  29.                 choice = console.next();
  30.                 choice = choice.toLowerCase();
  31.             }while(!choice.equals("l")&&!choice.equals("s"));
  32.  
  33.             if (choice.equals("s")){
  34.                 System.out.println("Enter Login Details");
  35.                 System.out.printf("Enter Username: ");
  36.                 uname[z] = console.next();
  37.                 System.out.printf("Enter Password: ");
  38.                 pword[z] = console.next();
  39.                 System.out.printf("Enter your Full Name: ");
  40.                 name[z] = console.next();
  41.                 System.out.printf("Enter Birthday in Month/Day/Year: ");
  42.                 bday[z] = console.next();
  43.                
  44.                 System.out.printf("Enter Grade for Programming (2 Units): ");
  45.                 subjects[z][0] = consoleDouble.nextDouble();
  46.                 System.out.printf("Enter Grade for Computing (3 Units): ");
  47.                 subjects[z][1] = consoleDouble.nextDouble();
  48.                 System.out.printf("Enter Grade for UTS (3 Units): ");
  49.                 subjects[z][2] = consoleDouble.nextDouble();
  50.                 System.out.printf("Enter Grade for STS (3 Units): ");
  51.                 subjects[z][3] = consoleDouble.nextDouble();
  52.                 System.out.printf("Enter Grade for PE (2 Units): ");
  53.                 subjects[z][4] = consoleDouble.nextDouble();
  54.                 z++;
  55.             }
  56.             else if (choice.equals("l")){
  57.                 System.out.println("Enter Login Details");
  58.                 System.out.printf("Enter Username: ");
  59.                 loginUname = console.next();
  60.                 for(x=0;x<1000;x++){
  61.                     if (loginUname.equals(uname[x])){
  62.                         x=y;
  63.                     }
  64.                 }
  65.                 System.out.printf("Enter Password: ");
  66.                 loginPword = console.next();
  67.                 if (loginPword.equals(pword[y])){
  68.                     login = true;
  69.                 }
  70.             }
  71.            
  72.             if (login == true){
  73.                 System.out.println("Name: \t"+name[y]);
  74.                 System.out.println("Birthday: \t"+bday[y]);
  75.                 System.out.println("Grades");
  76.                 System.out.println("Programming: \t"+subjects[y][0]);
  77.                 System.out.println("Computing: \t"+subjects[y][1]);
  78.                 System.out.println("UTS: \t\t"+subjects[y][2]);
  79.                 System.out.println("STS: \t\t"+subjects[y][3]);
  80.                 System.out.println("PE: \t\t"+subjects[y][4]);
  81.                 computation = ( ((subjects[y][0]*2)+(subjects[y][1]*3)+(subjects[y][2]*3)
  82.                         +(subjects[y][3]*3)+(subjects[y][4]*2)) / 13 );
  83.                 System.out.print("GWA: \t"+numberFormat.format(computation));
  84.             }
  85.            
  86.             do{
  87.                 System.out.printf("Do you want to exit? [Y]es / [N]o?: ");
  88.                 choice = console.next();
  89.                 choice = choice.toLowerCase();
  90.             }while(!choice.equals("y")&&!choice.equals("n"));
  91.             if (choice.equals("y"))
  92.                 exit=true;
  93.         }while(exit==false);
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement