Page 1 of 1

Please code in Java Programming Language. a) Design a class "Human" containing the following information: + name is a st

Posted: Fri Jul 01, 2022 5:51 am
by answerhappygod
Please code in Java Programming Language.
a) Design a class "Human" containing the followinginformation:+ name is a string of charactersIncludes the following functions+The constructor to set the variables in the class+ Can add some other functions if necessary.b) Design a class named Student, this class is derived from theclass "Person", in addition, the information of the class "Person",the Student class also has the following additionalinformation:+ Mark1: float+ Mark2 : float+ AverageMark: FloatFunctions:+ The constructor sets the values ​​of the variables of theclass+ Other functions if needed+ The getAVM function to determine the Average mark of eachstudent, the getAVM function returns the value: AVM =(mark1+2*mark2)/3 . If the last character of the name is 'B' or 'b'then the AVM value will be rounded up, otherwise it will be roundedaccording to the math rounding principle.class main.javaclass Main { public static void main(String args[]) throwsException { BufferedReader in = newBufferedReader(new InputStreamReader(System.in)); System.out.print("Enter name : "); String name = in.readLine(); System.out.print("Enter Mark1: "); double price =Double.parseDouble(in.readLine()); System.out.print("Enter Mark 2:"); double diem2 =Double.parseDouble(in.readLine()); System.out.print("Enter TC: "); int tc =Integer.parseInt(in.readLine()); System.out.println("OUTPUT:"); if(tc == 1) { Person b = newPerson(name); System.out.println(b); b = new student(name,mark1, weight); System.out.println(b); } else if(tc == 2) { student b = newstudent(name, price, weight); System.out.println(b.getAVM()); } } }
} }