0% found this document useful (0 votes)
8 views7 pages

Activity 8 Source Code

Source code for Java Programming

Uploaded by

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

Activity 8 Source Code

Source code for Java Programming

Uploaded by

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

Activity 8 Source Code

1.
package Activity8;

public class Employee {

public static void main(String[] args) {

Employee employee1 = new Employee();


employee1.setName("Employee 1");
employee1.setCompanyName("XYZ Company");
employee1.setYearsOfService(7);
employee1.setSalary(18000.00);

Employee employee2 = new Employee();


employee2.setName("Employee 2");
employee2.setCompanyName("ABC Company");
employee2.setYearsOfService(5);
employee2.setSalary(12000.00);

System.out.println(employee1.getName());
System.out.println("Company name: " + employee1.getCompanyName());
System.out.println("Years of service: " + employee1.getYearsOfService());
System.out.println("Salary: " + employee1.getSalary());

System.out.println();
System.out.println(employee2.getName());
System.out.println("Company name: " + employee2.getCompanyName());
System.out.println("Years of service: " + employee2.getYearsOfService());
System.out.println("Salary: " + employee2.getSalary());

private String name;


private String companyName;
private int yearsOfService;
private double salary;

public String getName(){


return name;
}

public String getCompanyName(){


return companyName;
}

public int getYearsOfService(){


return yearsOfService;
}

public double getSalary(){


return salary;
}

public void setName(String name){


this.name = name;
}

public void setCompanyName(String companyName){


this.companyName = companyName;
}

public void setYearsOfService(int yearsOfService){


this.yearsOfService = yearsOfService;
}

public void setSalary(double salary){


this.salary = salary;
}

2.
package Activity8;

public class Student {


public static void main(String[] args) {

Student student1 = new Student();


student1.setName("Student 1");
student1.setCourse("BSIT");
student1.setYear(1);

Student student2 = new Student();


student2.setName("Student 2");
student2.setCourse("BSCS");
student2.setYear(1);

System.out.println(student1.getName());
System.out.println("Course: " + student1.getCourse());
System.out.println("Year: " + student1.getYear());

System.out.println();

System.out.println(student2.getName());
System.out.println("Course: " + student2.getCourse());
System.out.println("Year: " + student2.getYear());

private String name;


private String course;
private int year;

public String getName(){


return name;
}

public String getCourse(){


return course;
}

public int getYear(){


return year;
}

public void setName(String name){


this.name = name;
}

public void setCourse(String course){


this.course = course;
}

public void setYear(int year){


this.year = year;
}

}
3.
package Activity8;

public class Bros {

public static void main(String[] args) {

Bros bro1 = new Bros();


bro1.setName("Giles");
bro1.setAge(21);

Bros bro2 = new Bros();


bro2.setName("Amier");
bro2.setAge(19);

Bros bro3 = new Bros();


bro3.setName("Jayden Avery");
bro3.setAge(9);

System.out.println(bro1.getName() + " is " + bro1.getAge() + " years old.");

System.out.println(bro2.getName() + " is " + bro2.getAge() + " years old.");

System.out.println(bro3.getName() + " is " + bro3.getAge() + " years old.");


}

private String name;


private int age;

public String getName(){


return name;
}

public int getAge(){


return age;
}

public void setName(String name){


this.name = name;
}

public void setAge(int age){


this.age = age;
}

You might also like