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

1 answer below »
Complete the tasks in the pdf file.


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=""><= 100="" a="" 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 array 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 array (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 array 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 array 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 brown89 85 92 99 90 10004 bob bush85 76 83 79 83 10010 carl capra65 57 73 68 76 10012 david lieberman76 68 79 81 58 10034 john menchin100 89 95 93 88 10056 george smith86 78 90 80 95 10062 elaine sanders85 79 90 80 95 10078 jack cunningham72 78 82 97 84 10090 susie brown68 85 80 84 83 10099 marvella garcia86 92 88 97 98 10120 tony peterson85 84 83 90 76 10129 john jones75 75 80 84 80 10131 mary evans60 72 89 86 65 10146 nancy drew78 80 75 90 85 10152 lola zapeta89 81 98 89 97 10155 duckey donald82 60 73 78 55 10163 goof goofy89 78 75 89 56 10168 brave balto100 98 93 89 92 10178 snow smitn93 76 54 83 80 10184 alice wonderful86 79 87 78 67 10192 samina akthar85 62 78 45 60 10207 simba green50 45 35 60 20 10211 donald egger76 80 83 68 81 10216 brown deer86 87 89 79 75 10245 johny jackson96 85 91 83 79 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="" array="" 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="" array="" (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="" array="" 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="" array="" 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="" 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="">
Answered Same DayOct 15, 2020BCS230

Answer To: Microsoft Word - BCS230_182_homework3.docx BCS 230: Foundations of Computer Programming II CRN...

Snehil answered on Oct 19 2020
148 Votes
hw3main.cpp
#include
#include
#include "Student.h"
#include
int mai
n()
{
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< cout< cout< cout< cout< cout< cout< cout< cout< 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