Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE LOOK AT THE RUNS!!! 2 . Create a new Java class named Student, according to the UML diagram. Specifications for the Student Class (
PLEASE LOOK AT THE RUNS!!!
Create a new Java class named Student, according to the UML diagram.
Specifications for the Student Class In combination with the UML:
Constructor without arguments will assign all field values based on your personal
information your student number, full name with a score of
Constructor with arguments will assign all field values based on the information
passed in the arguments.
printInfo prints out the three field values
with the help of the printf method. It uses field width and justification as shown in the sample output.
Note: in the sample output, the field width of and have been used to present the name, student number, score, and letter grade, respectively, and all the dataitems used left justification.
The accessorgetter method getName returns the students full name the first name followed by a space followed by the last name while getScore returns the score of a student.
The mutatorsetter methods setName setStudentName setScore will set the appropriate values see the UML diagram received from the user
The member method called getLetterGrade returns the letter grade for the corresponding score according to the table given below Hint: See Unit slide
Student
name: String studentNumber: int score: int
Student
Studentnm: String, sn: int, sc: intprintInfo: void
getName : String
getScore: int
setNamenm: String: void setStudentNumbersn: int: void setScoresc: int: void getLetterGrade : String
Score
Letter
Grade
or greater A A B B
C C D
or less F
In the same Java package, create a driver class with the name StudentGradesByYourFirstName YourFirstName should be your first name and do the following:
Page of
ESB Programming Fundamentals for Engineers
Lab Exercise
a Declare a public static Scanner type field and instantiate it Note: When in a class, we declare a Scanner type field called input we can use any valid name and instantiate it as public static Scanner input new ScannerSystemin;this field can be used in any of the static methods of this class. But if we declare a Scanner type reference variable as a local variable then this one can only be used inside the method that we declare it
b Declare another public static int type field called counter and assign it to zero value. This will keep the count of number of students inside the dataEntry method.
c Define a public static void method called dataEntry that has the following header:
public static void dataEntryStudent s
This method will receive a Student type reference in s and do the following inside the
method:
o Incrementtheintegertypefieldcounteryoudeclared;wewilluseittokeep track of the number of Students overall in a run. You can see in the sample output that it says Student etc. Please note that when you increment any static field inside any method, that incremented value remains the same for all the other methods inside the same class.
o Prompttheusertoenterthestudentnumber,andwiththeuseoftheScanner field declared in a get the value from the keyboard and store it in an appropriate variable. Note: the student number must be entered first otherwise, no mark will be awarded. The goal in maintaining this order is to test our understanding of bufferclearing dummycalls associated with the use of the nextLine method which we need for the next specification.
o Prompttheusertoenterthefullname,andwiththeuseofthesameScannerfield declared in a get the value from the keyboard and store it in an appropriate variable.
o Prompttheusertoenterthescore,andwiththeuseofthesameScannerfield declared in a get the value from the keyboard and store it in an appropriate variable.
o Youcanchooseanydigitstudentnumber,anyfullnamefirstnameandlast name with a space in between and any score between and Assume that the user will enter valid data only.
o Nowitwillsetalltheabovevaluestoswiththehelpofthesettermethods.
d Define a public static method called compareGrades that has the following header: public static int compareGradesStudent s Student s This method will receive two Student type references s and s and do the following:
o It will return if ss score is greater, else, it will return if ss score is greater, otherwise, if both are equal it will return
e Copy and paste the myHeader and myFooter methods you created in the previous lab.
f Now define the driver method with the following specifications:
o Inside the main method, call myHeader with appropriate arguments. o Declare a Student type reference variable s and instantiate it to create an
object with the help of the constructor without argument.
o Using the printInfo method print the information on the screen. Since you
have defined the constructor without parameter with your own information, the printInfo me
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started