0% found this document useful (0 votes)
24 views6 pages

Finaltestcsc186 (2019275786)

z

Uploaded by

acecap danial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views6 pages

Finaltestcsc186 (2019275786)

z

Uploaded by

acecap danial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Asyraf danial bin suhaimi

2019275786
Question1

File_Readers pp = new File_Readers("enrollment.txt");


BuffReaders ss = new BuffReaders(pp);
FileWriter_ za = new FileWriter("CS240_CTU553.txt");
BuffWriters_ sd = new BuffWriters(za);
PrintWriter_ sl = new PrintWriter(sd);

Enroll enrolls[] = new Enroll[1000];

int i = 0;
String info = null;
while(info = ss.readLine()) != null){

StringToken data = new StringToken(info,";");


String studName = data.nextToken();
String studentID = data.nextToken();
String prog = data.nextToken();
String course = data.nextToken();
enrolls[i] = new Enroll(studID, studName, program, course);

i++;
}

int count =0;


for(int a=0;a<enrolls.lengths;a++)
{
if(enrolls[a].getCourse() == "CTU551")
{
count++;
}

}
System.out.println("This are the total of student that register subject CTU551 which is about
" + count);
System.out.println();

for(int a=0;a<enrolls.length;a++)
{
if(enrolls[a].getCourse() == "CSC240" && enrolls[a].getProgram() == "CTU551" )
{
pw.println(enrolll[a].getStudentID());
pw.println(enrolll[a].getStudentName());
}

}
za.close();
pp.close();
}

catch(IOException ioe){
System.out.println("THE conflict issue : " + ioe.getMessage());
}
}

QUESTION 2
a)
1)
//superclass
courseRegisteration
//subclass
onlineClass

11)
TypeGraduate

111)
calculateFee because that are the method that already provided by the superclass.

b)
public class onlineClasses extends courseRegistration
{
public String programCode;

i) public onlineClassses(String o, String p, int z, char q, int b, String c)


{
super(o,p,q,a,b);
programCode = c;
}

ii) public void setProgramsCode (String n) {


programCode = n;
}

iii) public String getstudentID()


{
return super.studentsID;
}

public String getstudentName()


{
return super.studentsName;
}

public int getStudentAge()


{
return super.studentsAge;
}
public char getStudentGender()
{
return super.studentsType;
}

public int getStudentsType()


{
return super.studentsType;
}

public String getProgramCode()


{
return programsCode;
}

iv) public String toString()


{
super.toString();
return("The Program Code : "+ programCode);
}

v) Public double calculateFee()


{
double price = 0;
if(getProgramCode().equalsIgnoreCase(“COMP”)

if(getStudentType() = 1)
price = 1600 – (1600*0.4);
else
price = 2100 –(2100*0.3);

else if(getProgramCode().equalsIgnoreCase(“ENG”)
if(getStudentType() = 1)
price = 1600 – (1600*0.35);
else
price = 2100 –(2100*0.25);
return price;

C)
Import java.util.Scanner ;

Public static void main(String [] args){


online [ ] onlineClasses = new online[100];
for (int i=0;i<100;i++){
system.out.println(“Enter the code of the program: ”
String programsCode = in.nextString ;
system.out.println(“please enter the type of graduate bro (postgraduate/undergraduate): ”);
String TypeGradute = in.nextString ;
}
}

QUESTION 3
a)
public SchoolTeacher( String n , String ic , String sub , int yos,string grade){
super(n,ic,sub,yos);
this.grade = grade; }

B 1) public double calcSalary(){


int salary = 0;
if(grade.equals("DG41"))
salary= 2000;
else if(grade.equals("DG44"))
salary = 3400;
else if(grade.equals("DG48"))
salary = 5000;
else
salary = 5600;

return salary ;}
}

11)
public double calcSalary(){
int salary = 0 ;
if(super.getYos()<=2)
salary = 1300+ot*15;
else if(super.getYos()<=5)
salary = 1900+ot*15;
else if(super.getYos()>5)
salary = 2100+ot*15;
return salary;
}

C 1)
Teacher teach [] = new Teacher [20];

11)
for ( int box = 0; box < 20 ;box++){
if(teach[box].getYos()>10);
System.out.print(toString());
}
111)
import java.util.*;
public class onlineClassApp
{
public static void main (String []args)
{
Scan sc = new Scanner (System.in);
onlineClasses[] online = new onlineClass[100];

int i=0;
for (int i=0;i<online_length;i++)
{
System.out.println ("Please enter the Student ID: ");
String id = sc.next();

System.out.println ("Please Enter the Student name: ");


String name = sc.next();

System.out.println ("please Enter the Student gender: ");


char gen = sc.next();

System.out.println ("please Enter the Student Age: ");


int age= sc.nextInt();

System.out.println ("please Enter the student Type: ");


int type = sc.nextInt();

System.out.println ("please Enter Student’s program code now: ");


String prog = sc.next();

online [i]= new onlineClass (id,name,age,gen,type,prog);


}

for (int i=0;i<online.length;i++)


{
public double calculatetotalFee()
{
double fee = 0.0;

if(online [i].getProgramCode().equalsIgnoreCase("COMP") && online


[i].getstudentType() == 1)

fee += online [i].getcalculateFee();

return fee;
}

online[i].toString();
System.out.println("Total fee that are collected for undergraduate
students from the engineering program
1v)
for(int box = 0 ; box <teach.length ;box++){
if(teach[box] instance of SchoolTeacher){
SchoolTeacher st = (SchoolTeacher)teach[box];
if(st.getGrade().equals("DG44")
System.out.println("The Name: "+st[box].getName());
System.out.println("Their Salary :"+st[box].getSalary());
}//if
}
}
int countxo= 0;
for(int box = 0 ; box <teach.length;box++){
if(teach[box] instance of KindergartenTeacher){
KindergartenTeacher kt = (KindergartenTeacher)teach[box];
countox += kt[box].getox();
}
}
System.out.print("Total overtime hours that are done by the teachers was about "
+ countOT );

You might also like