Question: For Student.java coding 7 public class Student { 8 // attributes of a Student 9 private String firstName; 10 private String lastName; 11 private int

 For Student.java coding 7 public class Student { 8 // attributesof a Student 9 private String firstName; 10 private String lastName; 11private int studentId; 12 private double gpa; 13 14 15 public staticvoid main(String[] args) { 16 Student stu = new Student("Jane", "Brown", 182765,2.333); 17 //System.out.println(stu.toString()); 18 System.out.println(stu.getLastName() + ", " + stu.getFirstName()); 19 System.out.println("ID:

For Student.java coding

7 public class Student { 8 // attributes of a Student 9 private String firstName; 10 private String lastName; 11 private int studentId; 12 private double gpa; 13 14 15 public static void main(String[] args) { 16 Student stu = new Student("Jane", "Brown", 182765, 2.333); 17 //System.out.println(stu.toString()); 18 System.out.println(stu.getLastName() + ", " + stu.getFirstName()); 19 System.out.println("ID: " + stu.getStudentID() + " GPA: " + stu.getGPA()); 20 21 22 } 23 24 /** 25 * Student constructor. 26 * @param _fName student's first name 27 * @param _lName student's last name 28 * @param _id student's id number 29 * @param _gpa students GPA 30 */ 31 public Student(String _fName, String _lName, int _id, double _gpa) { 32 firstName = _fName; 33 lastName = _lName; 34 studentId = _id; 35 gpa = _gpa; 36 } 37 38 /** 39 * getFirstName - Accessor for first name 40 * @return the student's first name 41 */ 42 public String getFirstName() { 43 return firstName; 44 } 45 46 /** 47 * getLastName - Accessor for last name 48 * @return the student's last name 49 */ 50 public String getLastName() { 51 return lastName; 52 } 53 54 /** 55 * getId - Accessor for ID 56 * @return the student's ID 57 */ 58 public int getStudentID() { 59 return studentId; 60 } 61 62 /** 63 * getGpa - Accessor for gpa 64 * @return the student's gpa 65 */ 66 public double getGPA() { 67 return gpa; 68 } 69 70 /** 71 * setFirstName - Mutator for first name 72 * @param the new first name 73 */ 74 public void setFirstName(String _fName) { 75 firstName = _fName; 76 } 77 78 /** 79 * setLastName - Mutator for last name 80 * @param the new last name 81 */ 82 public void setLastName(String _lastName) { 83 lastName = _lastName; 84 } 85 86 /** 87 * setStudentId - Mutator for ID 88 * @param the new ID 89 */ 90 public void setStudentId(int _id) { 91 studentId = _id; 92 } 93 94 /** 95 * setGpa - Mutator for gpa 96 * @param the new gpa 97 */ 98 public void setGpa(double _gpa) { 99 gpa = _gpa; 100 } 101 }

For Address.java coding

1 public class Address { 2 private String street; 3 private String city; 4 private String state; 5 private int zip; 6 7 public static void main(String[] args) { 8 Address anAddress = new Address("13 Flower St.", "Pulteneyville", "NY" , 14386); 9 //System.out.print(anAddress.toString()); 10 System.out.println(anAddress.getStreetName()); 11 System.out.println(anAddress.getCityName() + ", " + anAddress.getStateName() + " " + anAddress.getZipCode()); 12 } 13 public Address(String _street, String _city, String _state, int _zipcode) { 14 street = _street; 15 city = _city; 16 state = _state; 17 zip = _zipcode; 18 } 19 20 public String getStreetName() { 21 return street; 22 } 23 24 public String getCityName() { 25 return city; 26 } 27 28 public String getStateName() { 29 return state; 30 } 31 32 public int getZipCode() { 33 return zip; 34 } 35 }

Exercise 1- A Class with Class Attributes (4 points) The exercise must be completed during the lab period. Download the Student-starter.zip file from myCourses and extract it to get Student.java 1. Add to the Student class a toString method so that the code Student stu - new Student ( "Jane", "Brown", 182765, 2.333) System.out.println(stu.toString()); will print: Brown, Jane ID: 182765 GPA 2.3 NOTE: The GPA is formatted via String.format using an appropriate format as in Lab03. There should be one digit to the left, and one digit to the right, of the decimal point 2. Write another class, Address.java with attributes private String street; private String city; private String state; private int zip; This represents an address. You should provide a constructor that expects a parameter for each of the above attributes and initializes the object to those values Also, write a toString() method that will print out the address. If the address is then will print: 3. Address anAddress-new ("13 Flower St.", "Pulteneyville", "NY", 14386); System.out.println(anAddress.toString()) 13 Flower St. Pulteneyville, NY 14386 4. Write a third class, StudentRecord, that has two attributes: Student stu; Address addr; and two constructors. The first constructor is given a Student object and an Address object to initialize the attributes. The second constructor is given a first name, a last name, a student ID, a gpa, a street address, a city, a state, and a zipcode and uses these to initialize the attributes 5. Provide in StudentRecorda toString) method that will return the toString() of the Student followed by a new line and then the tostring() of the Address 6. Finally, write a main program in the file TestStudentRecord.java that will initialize and print out the information for two students

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!