Test 3 Part B consists of three tasks: Debug and Modifya program. (C++)
DUE 11/26/19
Please note that to do well on Test 3 both Part A and Part Bmust be completed.
- Debug, (find the errors and correct them in),the program, T3DebugProg.cpp (worth 20points):
Note:
- The file is attached with this part of the test – downloadit.
- Note that there are 6 errors.
- For debug assignments — Overall Assignment worth 2 points:
- DO NOT take out comments
- DO NOT rearrange the code!
- DO NOT change the code standards!
- Each error you find is worth 3 points for 18points total.
- Find the bug
- Fix the bug
- Document the bug in the code to make it easy to fine
- You will lose points for incorrectly fixingthe bug.
- The program should run correctly when you have found andcorrected all 6 errors. Some are syntax andsome are logic errors.
- Submit both source code (*.cpp file),output files and screen print of runningprogram.
// Test Scores Debug // Debug Program — there are 6 errors in this program// Correct this program#include <iostream>#include <iomanip>using namespace std; void readData(ifstream& inputFile, int list[], int size);void holdscrn( ); // void function to hold screen open before exitint main(){ int scores[8] = {0}; ifstream infile; infile.open(“TestScoresData.txt”); if (infile) { cout << “Cannot open the input file. Program terminates!” << endl; holdscrn( ); // Hold screen before exit return 1; } readData(infile, scores, 8); print(scores, 8); cout << endl; infile.close(); holdscrn( ); // Hold screen before exit return 0;}void readData(ifstream& inputFile, int list[], int size){ int score; int index; cin >> score; while (inputFile) { index = score / 25; if (index == size) index–; if (index < size) list[index]++; inputFile >> score; } return 0;}void print(int list[], int size){ int range; int lowRange = 0; int upperRange = 24; cout << ” Range # of Students” << endl; for (range = 0; range < size; range++) { cout << setw(3) << lowRange << ” – ” << upperRange << setw(15) << list[range] << endl; lowRange = upperRange + 1; upperRange = upperRange + 25; if (range == size – 2) upperRange++; } cout << endl; return;}void holdscrn( ) // void function to hold screen open before exit{ char holdscreen; cout << “nntEnter one character and press return to exit program: “; cin >> holdscreen; return;}
Test Scores: Data
76 89 150 135 200 76 12 100 150 28 178 189 167 200 175 150 87 99 129149 176 200 87 35 157 189
- Modify the program (worth 20points)(C++):
Modify the Chapter 10Programming Example Abstract Creature program toadd the following:
- Add three more characters: Human,Elf and Dwarf
- Expand Orc to 3 Types ofOrcs: Minion, Warrior, and Boss
- Expand the Main to include a menu to greet allthe 3 alternate characters and the 3different types of Orcs.
Required for program grade:
- Source Code (complete)
- Screenshot of running program.
- Note partial credit will be givenfor incomplete programs that show progress from the originalprogram.
//Abstract Creature//Demonstrates abstract classes#include <iostream>using namespace std;class Creature //abstract class{public: Creature(int health = 100); virtual void Greet() const = 0; //pure virtual member function virtual void DisplayHealth() const;protected: int m_Health;};Creature::Creature(int health): m_Health(health){}void Creature::DisplayHealth() const{ cout << “Health: ” << m_Health << endl;}class Orc : public Creature{public: Orc(int health = 120); virtual void Greet() const;};Orc::Orc(int health): Creature(health){}void Orc::Greet() const{ cout << “The orc grunts hello.n”;}int main(){ Creature* pCreature = new Orc(); pCreature->Greet(); pCreature->DisplayHealth(); return 0;}
Expert Answer
Answer to Test 3 Part B consists of three tasks: Debug and Modify a program. (C++) DUE 11/26/19 Please note that to do well on Te…