Activity: Fix The Program Part II (iPad)

The Assignment

Working with your partner(s) and using the Adobe Acrobat Reader app on the iPad, open the FixTheProgram.pdf file stored on this device. This is an annotated PDF complete with corrections to make to the C++ code based on syntax errors, logic errors, and the C++ Coding Guidelines (on Canvas). Examine the contents of the document before proceeding.

The program shown below is the C++ program in question. Begin by creating a new C++ file called FixTheProgra,.cpp in the iPad C++ compiler. Next, copy and paste this code into the file. Modify the code to address the comments in the PDF.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>

///////////////////////////////////////////////////////////////////////////////
// Namespaces used....
///////////////////////////////////////////////////////////////////////////////
using namespace std;

double income = 0.0; // storage for the user income

int main()
{
double income; // storage for the amount of income
int exemptions = 0; // storage for the number of exemptions
double TAXES_due[4] = {0,0,0,0}; // storage for the taxes due
 
 while ( i < 6 ) {
 cin >> income >> exemptions;
 
 if ( income >= 40000 ) {
 TAXES_due[i] = income * 0.1;
 }
 else {
 if ( income >= 1000 ) {
 // compute the tax due, 5% of the income...
 TAXES_due[i] = income * 0.05; 
 } 
 }
 
 if ( TAXES_due[i] > 0 ) {
 // subtract $25 for every exemption...
 TAXES_due[i] -= (25 * exemptions); 
 }

 cout.setf( ios::fixed ); 
 cout.precision(2); 
 
 for ( int i = 0; i < 4; i-- ) { 
 // output the taxes due...
 cout << i << ": $" << TAXES_due[] << endl;
 }

 return 0;
 return 1;
}

When you have completed the assignment, demonstrate it for the instructor.