Vous êtes sur la page 1sur 12

SSK 3101 COMPUTER PROGRAMMING 2 LAB 7 ASSIGNMENT

NAME

: Abdul Azim Al Haziq Bin Abdul Malik

MATRIC NUMBER : 170100 GROUP INSTRUCTOR :6 : Pn. Wan Norlida bte Endut

(i) UML diagram


User
- matrix: String - markQuiz: double - markAss: double - markFirst: double - markSecond: double - markFinal: double - total: double - grade: char + setMetric( matrix: String ) + setmQuiz( markQuiz: double ) + setmLabAsg( markAss: double )
+ setmFirstTest( markFirst: double ) + setmSecondTest( markSecond: double )

+ setmFinal( markFinal: double ) + setmTotalMark() + setGrade() + getMetric(): String + getmQuiz(): double + getmLabAsg(): double + getmFirstTest(): double + getmSecondTest(): double + getmFinal(): double + getmTotalMark(): double + getGrade(): char

(ii) Coding
package StudentRecord; import java.util.Scanner; public class Student {

public static void main(String[] args) { //SEKARANG SISTEM AKU MULA LENGKAP <(>.<)> CREDIT TO Muhammad Asyraf bin Azwarrudin AND Aminah Abdul Muin :) love you guys xoxo :* Scanner input =new Scanner(System.in); Student[] Pelajar = new Student[10]; System.out.println(" COMPUTER PROGRAMMING 2"); System.out.println(" (SSK3101)"); System.out.println(" **********************************************STUDENT EVALUATION SYSTEM*************************************"); data_input (Pelajar, input); data_output(Pelajar); } public static void data_input(Student[] Pelajar, Scanner input){// data input int i = 0; String counter = null; double markQuiz = 0, markAss, markFirst, markSecond, markFinal ; for (int j=0 ; j < Pelajar.length ; j++){ Pelajar[j] = new Student();

} //Digunakan untuk cari student id do { System.out.println ("Please enter student ID"); String matrix = input.next();

do {//Digunakan untuk cari markah quiz System.out.println ("Please enter the quiz mark /15%"); markQuiz = input.nextDouble(); }while (markQuiz > 15); do{ // ini digunakan untuk scan markah lab assignment System.out.println ("Please enter assignment mark /15%"); markAss = input.nextDouble(); }while (markAss > 15); do{ //Method ini digunakan untuk scan markah first test System.out.println ("Please enter first test mark /15%"); markFirst = input.nextDouble(); }while(markFirst>15); do{ //Method ini digunakan untuk scan markah second test System.out.println ("Please enter second test mark /15%"); markSecond = input.nextDouble(); }while(markSecond>15); do{//Method ini digunakan untuk scan markah FINAL System.out.println ("Please enter FINAL mark /40%"); markFinal = input.nextDouble(); }while(markFinal>40);

Pelajar[i].setMetric(matrix); //---private method untuk no matrix Pelajar[i].setmQuiz(markQuiz); //---private method untuk quiz Pelajar[i].setmLabAsg(markAss);//---private method untuk assignment Pelajar[i].setmFirstTest(markFirst); //---private method untuk markah first test Pelajar[i].setmSecondTest(markSecond); //---private method untuk markah second test Pelajar[i].setmFinal(markFinal); //---private method untuk

markah final Pelajar[i].setmTotalMark(); //---private method untuk total mark Pelajar[i].setGrade(); //---private method untuk tentukan grade :) i++; //Digunakan untuk tau sama ada nak ulang kembali sistem or tak ---> Ini coding dari acap >.<v if(i<Pelajar.length){ System.out.print("\nEnter 1 to continue for next student, or any key to stop: "); counter = input.next(); } }while((counter.equals("1"))&&(i<Pelajar.length)); } public static void data_output(Student[] Pelajar){ System.out.println("\n\n"+"Metric Quiz Lab First Test Second Test Final Exam Total Mark Grade"); System.out.println("------------------------------------------------------------------------------------------------------------"); for(int i=0; i<Pelajar.length;i++){ if (Pelajar[i].getmQuiz()==0){ System.exit(0); } else{ System.out.println(Pelajar[i].getMetric()+" "+Pelajar[i].getmQuiz()+" "+Pelajar[i].getmLabArg()+ " "+Pelajar[i].getmFirstTest()+" "+Pelajar[i].getmSecondTest()+" "+Pelajar[i].getmFinal()+ " "+Pelajar[i].getmTotalMark()+" "+Pelajar[i].getGrade()); } } }

private private private private private private private private

String metric = new String(); double quiz; double lab; double test1; double test2; double exam; double total; char grade;

Student(){ } public void setMetric(String metric){ this.metric = metric; } public void setmQuiz(double quiz){ this.quiz=quiz; } public void setmLabAsg(double lab){ this.lab=lab; } public void setmFirstTest(double test1){ this.test1=test1; } public void setmSecondTest(double test2){ this.test2=test2; } public void setmFinal(double exam){ this.exam=exam; } public void setmTotalMark(){ total = quiz + lab + test1 + test2 + exam; } public void setGrade(){ if (total >= 80){

grade = 'A'; } else if (total >= 60){ grade = 'B'; } else if (total >= 40){ grade = 'C'; } else if (total >= 20){ grade = 'D'; } else { grade = 'E'; } }

public String getMetric(){ return metric; } public double getmQuiz(){ return quiz; } public double getmLabArg(){ return lab; } public double getmFirstTest(){ return test1; } public double getmSecondTest(){ return test2; } public double getmFinal(){ return exam;

} public double getmTotalMark(){ return total; } public char getGrade(){ return grade; } }

(vi) Result
COMPUTER PROGRAMMING 2 (SSK3101) **********************************************STUDENT EVALUATION SYSTEM************************************* Please enter student ID 166900 Please enter the quiz mark /15% 15 Please enter assignment mark /15% 13 Please enter first test mark /15% 13 Please enter second test mark /15% 13 Please enter FINAL mark /40% 13 Enter 1 to continue for next student, or any key to stop: 1 Please enter student ID 123321 Please enter the quiz mark /15% 11 Please enter assignment mark /15% 11 Please enter first test mark /15% 11 Please enter second test mark /15% 11 Please enter FINAL mark /40% 13 Enter 1 to continue for next student, or any key to stop: 1 Please enter student ID 180999 Please enter the quiz mark /15% 12 Please enter assignment mark /15% 12 Please enter first test mark /15% 12 Please enter second test mark /15%

13 Please enter FINAL mark /40% 33 Enter 1 to continue for next student, or any key to stop: 1 Please enter student ID 190899 Please enter the quiz mark /15% 11 Please enter assignment mark /15% 11 Please enter first test mark /15% 12 Please enter second test mark /15% 11 Please enter FINAL mark /40% 22 Enter 1 to continue for next student, or any key to stop: 1 Please enter student ID 170100 Please enter the quiz mark /15% 15 Please enter assignment mark /15% 15 Please enter first test mark /15% 15 Please enter second test mark /15% 15 Please enter FINAL mark /40% 40 Enter 1 to continue for next student, or any key to stop: 1 Please enter student ID 176567 Please enter the quiz mark /15% 12 Please enter assignment mark /15% 13 Please enter first test mark /15% 13 Please enter second test mark /15% 13 Please enter FINAL mark /40%

13 Enter 1 to continue for next student, or any key to stop: 1 Please enter student ID 111111 Please enter the quiz mark /15% 11 Please enter assignment mark /15% 11 Please enter first test mark /15% 11 Please enter second test mark /15% 11 Please enter FINAL mark /40% 11 Enter 1 to continue for next student, or any key to stop: 1 Please enter student ID 179076 Please enter the quiz mark /15% 12 Please enter assignment mark /15% 14 Please enter first test mark /15% 14 Please enter second test mark /15% 14 Please enter FINAL mark /40% 14 Enter 1 to continue for next student, or any key to stop: 1 Please enter student ID 189011 Please enter the quiz mark /15% 15 Please enter assignment mark /15% 15 Please enter first test mark /15% 15 Please enter second test mark /15% 15 Please enter FINAL mark /40% 15

Enter 1 to continue for next student, or any key to stop: 0

Metric Quiz Lab First Test Second Test Final Exam Total Mark Grade ------------------------------------------------------------------------------------------------------------166900 15.0 13.0 13.0 13.0 13.0 67.0 B 123321 11.0 11.0 11.0 11.0 13.0 57.0 C 180999 12.0 12.0 12.0 13.0 33.0 82.0 A 190899 11.0 11.0 12.0 11.0 22.0 67.0 B 170100 15.0 15.0 15.0 15.0 40.0 100.0 A 176567 12.0 13.0 13.0 13.0 13.0 64.0 B 111111 11.0 11.0 11.0 11.0 11.0 55.0 C 179076 12.0 14.0 14.0 14.0 14.0 68.0 B 189011 15.0 15.0 15.0 15.0 15.0 75.0 B

Vous aimerez peut-être aussi