Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

with java Student class : class Student{ private String first; private String last; private double grade; private static int studentNumber=0; Student(){ studentNumber++; } Student(String f,

with java
Student class :
class Student{
private String first;
private String last;
private double grade;
private static int studentNumber=0;
Student(){
studentNumber++;
}
Student(String f, String l,double g){
first=f;
last=l;
grade=g;
studentNumber++;
}
public void showStudent() {
System.out.println("Name:"+ first+ " "+ last +" Grade:"+grade);
}
public String getFirst(){
return first;
}
public void setFirst(String newFirst){
first=newFirst;
}
public static int getStudentNumber(){
return studentNumber;
}
}
public class TestStudent {
public static void main(String[] args) {
Student S1=new Student();
Student S2=new Student("Nourah","Janbi",4.8);
S1.showStudent();
S2.showStudent();
Student S3;
S3 = S2;
System.out.println("S1:"+S1);
System.out.println("S2:"+S2);
System.out.println("S3:"+S3);
S1.setFirst("Amal");
S2.setFirst("Sara");
System.out.println("s1 first name:"+S1.getFirst());
System.out.println("s2 first name:"+S2.getFirst());
System.out.println("Student number:"+Student.getStudentNumber());
}
}
image text in transcribed
Question 6.1: Consider the Student class with its private instance variables (Lab 5) and the following methods: 14. The constructor 1 that do nothing. 15. The getGrade method that returns the grade of one student. 16. The static showStudent method that uses a student object as parameter and displays the information of this object. a. Add the read method that reads from the keyboard the information of one student. The grade should be between 40 and 100 . 17. In the TestStudent class with main method, a. Create 3 objects S1, S2 and S3. b. Read the information of each student. c. Show the average of the grades. Question 6.2: 1. Now create a static read method in TestStudent class that creates a student object, reads the information of this object and returns it. What you should add in the Student class to write the read method? 2. How to call this method in main to read the information of the three students. 3. Show the information of each student using showStudent method. Question 6.3: 1. Now in main method, consider an array STUD of 3 students instead of S1, S2 and S3. 2. Call the read method of the TestStudent class to fill the Array of Students. 3. Modify the showStudent method to show the students with grades greater or equal to 60

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions

Question

5-1. Organizational buyers are ___________.

Answered: 1 week ago

Question

What are the basic financial decisions ?

Answered: 1 week ago

Question

What is meant by 'Wealth Maximization ' ?

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago