Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, My answer does not work what should I have to add here? package academicsystem; import java.time.LocalDate; import java.time.Month; import java.util.ArrayList; class Student { private

Hello, My answer does not work what should I have to add here?

package academicsystem;

import java.time.LocalDate;

import java.time.Month;

import java.util.ArrayList;

class Student {

private String firstname;

private String lastname;

private String street;

private String place;

private String zip;

private String address;

private int sno;

private LocalDate dob;

private LocalDate doj;

public Student(String firstname, String lastname, String street, String place, String zip, String address, int sno, LocalDate doj, LocalDate dob) {

this.firstname = firstname;

this.lastname = lastname;

this.street = street;

this.place = place;

this.zip = zip;

this.address = address;

this.sno = sno;

this.dob = dob;

this.doj = doj;

if(getStudentAge()>100){

throw new IllegalArgumentException("Please check the year entered, student cannot be over 100 years old");

}

}

// function to collate and return address

public String getStudentAddress() {

return street+" "+place+" "+zip;

}

// set new address

public void changeAddress(String street, String place, String zip) {

this.street = street;

this.place = place;

this.zip = zip;

}

// print student name and number when student object is printed

public String toString(){

return firstname+" "+lastname+", student number: "+sno;

}

public int getStudentAge(){

return LocalDate.now().getYear()-dob.getYear();

}

}

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions