Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Microsoft Word - JL_BCS345_201_homework3.docx BCS 345: Java Programming CRN 21177, 25160 JL Spring 2020...

1 answer below »
Microsoft Word - JL_BCS345_201_homework3.docx
BCS 345: Java Programming
CRN 21177, 25160 JL Spring 2020
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Homework 3  Monday, March 9
Due Saturday, April 4, 11:59PM in Blackboard
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Objectives: To learn to define and implement classes and use classes and objects to manipulate data.

Tasks:
Read the entire document before start NetBeans.
Create a Java application project named BCS345hw3 which contains two public classes, BCS345hw3
and Student. The BCS345hw3 class serves as a driver program and the Student class defines fields
and methods about a student object.
Your program will read student’s ID, first name, last name, and 5 scores from an input file
hw3data.txt, calculate the average test score after the lowest test score is dropped, and then assign a
letter grade to student using the following grade scale:
90 <= average <= XXXXXXXXXXA
80 <= average < 90 B
70 <= average < 80 C
60 <= average < 70 D
0 <= average < 60 F

The program must output each student’s ID, full name, 5 scores, average, and letter grade in a neat format
similar to the sample output.
A. (40 points) Define the Student class and implement it as required. The Student class has the
following private instance fields.
No. Instance Fields Description
1 ID An int variable that holds a student’s ID.
2 firstName A string variable that holds a student’s first name.
3 lastName A string variable that holds a student’s last name.
4 scores An int a
ay that holds a student’s 5 test scores.

The Student class has the following public instance methods.
No. Instance Methods Description
1 No-arg constructor Sets ID to 0, firstName and lastName to “No Name”, and all
elements of scores to 0.
2 Overloaded constructor Accepts a student’s ID, first name, last name, and an int a
ay
(storing 5 scores) as arguments to set the fields of a Student object.
3 Copy constructor Uses the values of an existing Student object to create and instantiate
a new Student object.
4 setID Accepts an int argument and copies it into the ID instance field.
5 setFName Accepts a string argument and copies it into the firstName
field.
6 setLName Accepts a string argument and copies it into the lastName field.
7 setScores Accepts an int a
ay argument and copies it into the scores field.
8 getID Returns the value in ID.
9 getFName Returns the value in firstName.
10 getLName Returns the value in lastName.
11 getScores Returns an int a
ay that stores all 5 scores of a Student object.
12 getAverage Calculates the average test score after the lowest test score is dropped
and returns the average test score as a floating-point value. Precision
must be kept in the calculation.
13 getGrade Returns the letter grade based on the student’s average test score.
Hint: call the getAverage method to get the average score.
14 toString Output a student’s ID, first name, last name, 5 test scores, average
test score, and the letter grade. Format the output and set each field to
a fixed width.

B. (20 points) In the driver program, write statements to test your class implementation including all the
constructors and member methods.
C. (40 points) Suppose that the input data file contains the records of 25 students, in the driver program,
use an a
ay to manage 25 Student objects, read from the data file, instantiate the student objects,
process data, and output the results. Code efficiency must be taken into consideration.
The hw3data.txt file can be downloaded separately. Assume all the data are valid. The data file must
e placed directly in the project folder (at the same level of src folder) if file path is not provided.
Submission:
Submit your two source code files in Blackboard. The file name are case-sensitive and must be
BCS345hw3.java and Student.java. Use the default package for your project. Points will be
deducted for submission that doesn’t meet the name and package requirements.
Be sure to include the integrity statement I certify that this submission is my own original work with
your name and RAM ID in all your source files.
Sample output for part C:

10001 Alice Brown             XXXXXXXXXX
10004 Bob Bush                 XXXXXXXXXX
10010 Carl Capra             XXXXXXXXXX
10012 David Lieberman     XXXXXXXXXX
10034 John Menchin         XXXXXXXXXX
10056 George Smith         XXXXXXXXXX
10062 Elaine Sanders     XXXXXXXXXX
10078 Jack Cunningham     XXXXXXXXXX
10090 Susie Brown             XXXXXXXXXX
10099 Marvella Garcia     XXXXXXXXXX
10120 Tony Peterson         XXXXXXXXXX
10129 John Jones             XXXXXXXXXX
10131 Mary Evans             XXXXXXXXXX
10146 Nancy Drew             XXXXXXXXXX
10152 Lola Zapeta             XXXXXXXXXX
10155 Duckey Donald         XXXXXXXXXX
10163 Goof Goofy             XXXXXXXXXX
10168 Brave Balto             XXXXXXXXXX
10178 Snow Smitn             XXXXXXXXXX
10184 Alice Wonderful XXXXXXXXXX
10192 Samina Akthar         XXXXXXXXXX
10207 Simba Green             XXXXXXXXXX
10211 Donald Egger         XXXXXXXXXX
10216 Brown Deer         XXXXXXXXXX
10245 Johny Jackson         XXXXXXXXXX
Answered Same Day Mar 22, 2021 BCS345

Solution

Aditya answered on Mar 24 2021
155 Votes
BCS345hw3/a.txt
1
2
3
4
5
6
4
7
8
9
BCS345hw3
uild.xml

Builds, tests, and runs the project BCS345hw3.


BCS345hw3
uild/classes/.netbeans_automatic_build
BCS345hw3
uild/classes/.netbeans_update_resources
BCS345hw3
uild/classes
cs345hw3/BCS345hw3.class
package bcs345hw3;
public synchronized class BCS345hw3 {
public void BCS345hw3();
public static void main(String[]);
}
BCS345hw3
uild/classes
cs345hw3/Student.class
package bcs345hw3;
synchronized class Student {
private int id;
private String firstName;
private String lastName;
private int[] scores;
private float average;
private char grade;
void Student();
void Student(int, String, String, int[]);
void Student(Student);
public int getId();
public void setId(int);
public String getFirstName();
public void setFirstName(String);
public String getLastName();
public void setLastName(String);
public String getScores();
public void setScores(int[]);
float getAverage();
char getGrade();
void tostring();
}
BCS345hw3/hw3data.txt
10001 Alice Brown 89 85 92 99 90
10004 Bob Bush 85 76 83 79 83
10010 Carl Capra 65 57 73 68 76
10012 David Lieberman 76 68 79 81 58
10034 John Menchin 100 89 95 93 88
10056 George Smith 86 78 90 80 95
10062 Elaine Sanders 85 79 90 80 95
10078 Jack Cunningham 72 78 82 97 84
10090 Susie Brown 68 85 80 84 83
10099 Marvella Garcia 86 92 88 97 98
10120 Tony Peterson 85 84 83 90 76
10129 John Jones 75 75 80 84 80
10131 Mary Evans 60 72 89 86 65
10146 Nancy Drew 78 80 75 90 85
10152 Lola Zapeta 89 81 98 89 97
10155 Duckey Donald 82 60 73 78 55
10163 Goof Goofy 89 78 75 89 56
10168 Brave Balto 100 98 93 89 92
10178 Snow Smitn 93 76 54 83 80
10184 Alice Wonderful 86 79 87 78 67
10192 Samina Akthar 85 62 78 45 60
10207 Simba Green 50 45 35 60 20
10211 Donald Egger 76 80 83 68 81
10216 Brown Deer 86 87 89 79 75
10245 Johny Jackson 96 85 91 83 79
BCS345hw3/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
BCS345hw3/nbproject
uild-impl.xml








































































































































































































Must set src.di
Must set test.src.di
Must set build.di
Must set dist.di
Must set build.classes.di
Must set dist.javadoc.di
Must set build.test.classes.di
Must set build.test.results.di
Must set build.classes.excludes
Must set dist.ja




































































































Must set javac.includes





















































































































...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here