Please help me on these questions on my Java Program Questions 1-7 involve writing a Java storage class called Student that keeps track of a student's first name, last name and the number of credits being taken in a semester.. Write down the declarations for the instance variables.
Please help me on these questions on my Java Program
Questions 1-7 involve writing a Java storage class called Student that keeps track of a student's first name, last name and the number of credits being taken in a semester.. Write down the declarations for the instance variables.
Question 2: Write down the mutator methods for the instance variables. You don't need to check for the passed values other than trimming any String values.
Question 3: Write down a constructor that allows setting all of the instance variables. You can simply call the mutator methods you came up with in question 2.
Question 4: Write down all the accessor methods for the instance variables.
Question 5:
Create a toString() method that will return:
Jane Doe, credits: 12
if Jane Doe is taking 12 credits
Question 6: Rewrite the mutator for the first name, so that if a blank String is passed to this method, the first name is set to "NOFIRST".
Question 7: Rewrite the mutator for the number of credits, so that if a negative value is passed for the credits, credits is set to zero.
According to the Bartleby guideline, we are supposed to answer only one question at a time.
Kindly repost the remaining question and mentioned it
We have to declare the instance variable with storage class called Student
as we know an instance variable is a variable that is declared in a class, but outside of constructors, methods, or blocks. Instance variables are created when an object is instantiated and are accessible to any constructors, methods, or blocks in the class. Access modifiers can be assigned to instance variables.
Step by step
Solved in 2 steps with 2 images