Answer to Question #317721 in Java | JSP | JSF for oslo

Question #317721

a) Create a java project named school

b) Add two classes, namely student and lecturer

c) In student class, create the following methods:

i. calculate_stud_age – This method should take year of birth of the student as a

parameter and calculate and return the student’s age

ii. calculate_ave_mark – This method should take three marks of the student ,

Math, English and Physics marks as parameters and return the average mark

d) In the lecturer class, create the following methods:

i. get_name – This method should take a string (name of the lecture) and

an integer (experience of the lecturer in years). This method should

output/display the name of the Lecture together with his/her designation

based on the years of experiences determined by the following:

Professor – if experience is >= 20 years

Associate professor – if experience is >=15 years

Senior lecturer – if experience is >= 10 years

Associate lecturer – if experience is >=5 years

Junior lecturer – if experience is <5 years


1
Expert's answer
2022-03-24T16:21:17-0400
import java.util.Scanner;

class Student{

    public int calculate_stud_age(int birth){
        return 2022 - birth;
    }

    public double calculate_ave_mark(double math, double engl, double phys){
        return (math+engl+phys)/3;
    }
}

class Lect{
    public void get_name(String name, int experience){
        if(experience < 5){
            System.out.println("Lecturer's name: " + name + "\nBy his appointment Junior lecturer");
        } else if(experience >=5 & experience < 10){
            System.out.println("Lecturer's name: " + name + "\nBy his appointment Associate lecturer");
        } else if(experience >=10 & experience < 15){
            System.out.println("Lecturer's name: " + name + "\nBy his appointment Senior lecturer");
        } else if(experience >=15 & experience < 20){
            System.out.println("Lecturer's name: " + name + "\nBy his appointment Associate professor");
        } else if(experience >= 20){
            System.out.println("Lecturer's name: " + name + "\nBy his appointment Professor");
        }
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        Student student = new Student();
        Lect lect = new Lect();

        System.out.print("Enter student's year of birth: ");
        int yearsOld = student.calculate_stud_age(in.nextInt());
        System.out.print("Enter his math grade: ");
        int math = in.nextInt();
        System.out.print("Enter his English grade: ");
        int engl = in.nextInt();
        System.out.print("Enter his grade in physics: ");
        int phys = in.nextInt();
        System.out.println("Student age: " + yearsOld + "\nAverage score in subjects: " + student.calculate_ave_mark(math, engl, phys));

        System.out.print("Enter lecturer's name: ");
        String name = in.next();

        System.out.print("Enter lecture experience in years: ");
        lect.get_name(name, in.nextInt());

    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS