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

Microsoft Word - BCS230_182_homework3.docx BCS 230: Foundations of Computer Programming II CRN 90110, 90111 JL Fall 2018...

1 answer below »
Microsoft Word - BCS230_182_homework3.docx
BCS 230: Foundations of Computer Programming II
CRN 90110, 90111 JL Fall 2018
----------------------------------------------------------------------------------------------------------------------------------
Homework 3 − Wednesday, October 10
Due Wednesday, October 24, 11:59PM on Blackboard
----------------------------------------------------------------------------------------------------------------------------------------------------------
Objective: To learn to define and implement classes, and place class definition and class
implementation in separate files; to learn to use classes and objects to manipulate data.
Task:
Write a program that will read student’s ID, first name, last name, and 5 scores from an input file
“hw3data.txt”. The 5 scores are midterm exam score, final exam score, homework score, lab score,
and quiz score. The program calculates a student’s weighted total based on the formula:
Weighted total = 30%(midterm score) + 20%(final exam score) + 30%(homework score) +
10%(lab score) + 10%(quiz score).
And then assigns a letter grade to student using the grade scale:
90 <= weighted total <= XXXXXXXXXXA
80 <= weighted total < 90 B
70 <= weighted total < 80 C
60 <= weighted total < 70 D
0 <= weighted total < 60 F
The program should output each student’s ID, full name, 5 scores, weighted total, and letter grade in a
neat format.
A. (40 points) Your program should define a class Student and implement it as required. The class
Student should have the following private member variables.
Member Variable Description
ID An int variable that holds a student’s ID.
firstName A string variable that holds a student’s first name.
lastName A string variable that holds a student’s last name.
scores An int a
ay that holds a student’s 5 scores in the order of midterm exam
score, final exam score, homework score, lab score, and quiz score.
The class Student should also have the following public member functions.
Member Function Description
Default constructor Initializes an object’s member variables as follows: set ID to 0,
firstName and lastName to empty string, and all elements of scores
to 0.
Overloaded constructor Accepts a student’s ID, first name, last name, and an int a
ay (storing 5
scores) as arguments and uses these values to initialize appropriate member
variables of an object.
setID Accepts an int argument and copies it into the ID member variable.
setFName Accepts a string argument and copies it into the firstName member
variable.
setLName Accepts a string argument and copies it into the lastName member
variable.
setScores Accepts an int a
ay argument and copies it into the scores member
variable.
getID Returns the value in ID.
getFName Returns the value in firstName.
getLName Returns the value in lastName.
getWeightedTotal Calculates and returns the weighted total as a floating-point value. The
weight for the midterm score, final score, homework score, lab score, and
quiz score is 30%, 20%, 30%, 10%, and 10%, respectively.
getGrade Finds and returns the letter grade based on the student’s weighted total.
printStudent Outputs a student’s ID, first name followed by a space, followed by last
name, and followed by 5 scores, weighted total, and letter grade. Align each
column in a neat format as shown in the sample output.
B. (20 points) In the client program, you should write statements to test your class implementation
including all the constructors and member functions.
C. (40 points) Suppose that the input data file contains the records of 25 students. Use an a
ay of
Student that holds 25 objects. In the main function, the program reads from the data file and calls
member functions of class Student to set member variables and output the results.
The hw3data.txt file can be downloaded separately. Assume all the data are valid.
Submission:
You should submit a ZIP file that contains three files:
the class header file Student.h,
the class implementation file Student.cpp
and the test program hw3main.cpp.
Do NOT use any other names for the above three files (case-sensitive).
Be sure to include the integrity statement “I certify that this submission is my own original work” with
your name and RAM ID in each source file.
A sample output for Task 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 Oct 15, 2020 BCS230

Solution

Snehil answered on Oct 19 2020
159 Votes
hw3main.cpp
#include #include #include "Student.h"
#include int main()
{
int s[5]={89,85,92,99,90},s2[5];
Student a,b(10001,"Alice","Brown",s);
a.printStudent();
b.printStudent();
a.setFName("first");
a.setLName("last");
a.setScores(s);
a.setID(1234);
a.printStudent();
cout
.getID()
endl;
cout
.getFName()
endl;
cout
.getLName()
endl;
cout
.getWeightedTotal()
endl;
cout
.getGrade()
endl
endl;
cout
setw(11)
left
"Student ID"
setw(20)
"Full Name";
cout
setw(14)
ight
"Scores";
cout
setw(25)
ight
"Weighted Total"
setw(7)
"Grade";
cout
endl;
ifstream fin("hw3data.txt");
Student students[25];
int temp[5], id;
string fname,lname;
for(int i=0;i<25;i++)
{
fin
id
fname
lname;
for(int j=0;j<5;j++)
{
fin
temp[j];
}
students[i].setID(id);
students[i].setFName(fname);
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here