Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question1! JAVA CODES PLEASE Question2! In this question, you are asked to write

ID: 3838324 • Letter: Q

Question

Question1! JAVA CODES PLEASE

Question2!

In this question, you are asked to write a Student class, and an application that uses this Student class The Student class should contain the following attributes and methods: Attributes: studentD long StudentName: String markEOLMaths int markEOLEnglish int setName String) setStudentID( long setMarkForMaths in setMarkForEnglish(int) getName0 String getStudentIDG) ong getMarkForMaths0 int getMarkForEnglish00 int calculate AverageMark0 double First, write the code for the Student class. You should note that in order to ensure that a double is returned from the calculateAverageMark method you should specifically divide the total of the two marks by 2.0 and not simply by 2. Secondly, write a tester class StudentDriver. which have a main method to test out your Student class: it should create two students, and use the methods of the Student class. Analyze sample output below while writing the code of your two classes. mportant Notice Inside calculateAverageMark0 method, you must call getMathsMarko and getEnglishMarkO methods to get the student's marks. Sample output: Enter first student name:Cagatay Civici Enter first student number: 23645 Enter first student math mark:90 Enter first student english mark:90 First student GPA: 90.0 Enter second student name:Nesrin Kalender Enter second student number:98776 Enter second student math mark:100 Enter second student english mark: 100 Second student GPA:100.0

Explanation / Answer

import java.util.Scanner;

class Student{
long studentId;
String studentName;
int markForMaths;
int markForEnglish;

public void setstudentId(long id){
this.studentId = id;
}

public void setstudentName(String name){
this.studentName = name;
}

public void setmarkForMaths(int m1){
this.markForMaths = m1;
}

public void setmarkForEnglish(int m2){
this.markForEnglish = m2;
}

/*-----------------------------------------------*/
public long getstudentId(){
   return studentId;
}

public String getstudentName(){
   return studentName;
}

public int getmarkForMaths(){
   return markForMaths;
}

public int getmarkForEnglish(){
   return markForEnglish;
}

/*------------------------------------------------*/

    public double calculateAverageMark(){
return (markForEnglish + markForMaths)/2.0;
}

}

public class StudentDriver{
public static void main(String args[]){

int m1,m2;
long sid;
String name;
Scanner sc=new Scanner(System.in);
Student s1=new Student();//creating an object of Student
Student s2=new Student();//creating an object of Student

System.out.println("Enter first student name: ");
name = sc.next();
s1.setstudentName(name);

System.out.println("Enter first student number: ");
sid = sc.nextLong();
s1.setstudentId(sid);

System.out.println("Enter first student math mark: ");
m1 = sc.nextInt();
s1.setmarkForMaths(m1);

System.out.println("Enter first student english mark: ");
m2 = sc.nextInt();
s1.setmarkForEnglish(m2);

System.out.println("first student GPA : " + s1.calculateAverageMark());


System.out.println("Enter second student name: ");
name = sc.next();
s2.setstudentName(name);

System.out.println("Enter second student number: ");
sid = sc.nextLong();
s2.setstudentId(sid);

System.out.println("Enter second student math mark: ");
m1 = sc.nextInt();
s2.setmarkForMaths(m1);

System.out.println("Enter second student english mark: ");
m2 = sc.nextInt();
s2.setmarkForEnglish(m2);

System.out.println("Second student GPA : " + s2.calculateAverageMark());
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote