Question: 1) Debug, (find the errors and correct them in), the program, ''Debug.cpp'' Note: a. The file is attached with this part of the test download
1) Debug, (find the errors and correct them in), the program, ''Debug.cpp''
Note:
a. The file is attached with this part of the test download it.
b. Note that there are 6 errors.
c. For debug assignments Overall Assignment worth 2 points :
DO NOT take out comments
DO NOT rearrange the code!
DO NOT change the code standards!
d. Each error you find is worth 3 points for 18 points 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 fixing the bug.
e. The program should run correctly when you have found and corrected all 6 errors. Some are syntax and some are logic errors.
f. Submit both source code (*.cpp file) and screen print of running program (your output).
2) Write a simple text adventure game program (worth 20 points):
Design & Implement a very simple text adventure game treasure hunt/escape
Program Requirements:
Create a simple Design/Imp document to organize program include game algorithm.
Choose an adventure game setting like a Haunted House, Dungeon,
Have 5-8 areas (with simple descriptions) to travel from start to end.
Main character has a small backpack to pick up items, treasure unlock doors, etc.
Create Program with Program Heading, Game Intro, Game Exit, and good comments.
Include Running Game screen shots in Design/Imp document.
Submit your program source (*.cpp) file(s) and Design/Imp document with screen print of running code to receive credit.
input file for this debug
Today we live in an era where information is processed almost at the speed of light. Through computers, the technological revolution is drastically changing the way we live and communicate with one another. Terms such as the Internet, which was unfamiliar just a few years ago, are very common today. With the help of computers you can send letters to, and receive letters from, loved ones within seconds. You no longer need to send a rsum by mail to apply for a job; in many cases you can simply submit your job application via the Internet. You can watch how stocks perform in real time, and instantly buy and sell them. Students regularly surf the Internet and use computers to design their classroom projects. They also use powerful word processing software to complete their term papers. Many people maintain and balance their checkbooks on computers.
//*************************************************************
// Debug program
//
// Modified program from my old D.S. Malik book - by PMBetts
// Modified to be a good Test Debug program with 6 bugs.
//
// Program: Line and Letter Count
// This programs reads a text, outputs the text as is, and also
// prints the number of lines and the number of times each
// letter appears in the text. An uppercase letter and a
// lowercase letter are treated as being the same; that is,
// they are tallied together.
//*************************************************************
#include
#include
using namespace std;
void initialize(int& lc, int list[]);
void copyText(ifstream& intext, ofstream& outtext, char& ch,
int list[]);
void writeTotal(ofstream& outtext, int lc, int list[]);
int main()
{
//Step 1; Declare variables
int lineCount;
int letterCount[26];
char ch;
ifstream infile;
ofstream outfile;
// Tell User what the program is doing
cout << " Reads a text paragraph from testin.txt file then counts "
<< "lines and letters and outputs to textout.txt file. ";
// Open input and output files
infile.open("textin.txt"); //Step 2
if (infile) //Step 3
{
cout << "Cannot open the input file."
<< endl;
return 1;
}
// Process Data and send data to output file
cout << " \t *** Processing Input File Data and Creating
<< "Output File *** ";
outfile.open("textout.txt"); //Step 4
initialize(lineCount, letterCount); //Step 5
infile.get(ch); //Step 6
while (infile) //Step 7
{
copyText(infile, outfile, ch, letterCount); //Step 7.1
lineCount++ //Step 7.2
infile.get(ch); //Step 7.3
}
writeTotal(outfile, lineCount, letterCount); //Step 8
// Close files
infile.close(); //Step 9
outfile.close(); //Step 9
// Holdscreen for those systems that need it.
cout << " \tPress a Character and Press Enter to Exit! ";
cin >> ch;
return 0;
}
void initialize(int& lc, int list[])
{
int j;
lc = 0;
for (j = 0; j < 26; j++)
list[j] = 0;
} //end initialize
void copyText(ifstream& intext, ofstream& outtext, char& ch,
int list[])
{
while (ch != ' ') //process the entire line
{
outtext << ch; //output the character
characterCount(ch, list); //call the function
//character count
intext.get(ch); //read the next character
}
outtext << ch; //output the newline character
} //end copyText
void characterCount(char ch, int list[])
{
int index;
ch = toupper(ch); //Step a
index = static_cast
- static_cast
if (0 <= index && index < 26) //Step c
list[index]++;
} //end characterCount
void writeTotal(ofstream& outtext, int lc, int list[])
{
int index;
outtext << endl << endl;
cout << "The number of lines = " << lc << endl;
for (index = 0; index < 26; index++)
outtext << static_cast
<< " count = " << list[index] << endl;
} //end writeTotal
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
