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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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()); } } }
} }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply