Modify Project 8, Upload Project 9 Files
+- Project_8.c modified, subject to 80 char limit. ++ Project 9 Files Added
This commit is contained in:
parent
d8c2da56af
commit
deffe66afe
15 changed files with 2924 additions and 9 deletions
|
|
@ -130,7 +130,8 @@ Device Input/Keyboard: none
|
|||
Device Output/Monitor: none
|
||||
Dependencies: openInputFile, readDoubleFromFile, skipOneRow, readCharacterFromFile
|
||||
*/
|
||||
void uploadTaxTable(char dataFileName[], double taxDataArray[TAX_TABLE_R_COUNT][TAX_TABLE_C_COUNT])
|
||||
void uploadTaxTable(char dataFileName[],
|
||||
double taxDataArray[TAX_TABLE_R_COUNT][TAX_TABLE_C_COUNT])
|
||||
{
|
||||
// initialize variables
|
||||
int incrementerRow, incrementerCol;
|
||||
|
|
@ -154,21 +155,25 @@ void uploadTaxTable(char dataFileName[], double taxDataArray[TAX_TABLE_R_COUNT][
|
|||
// in the loop, read the double, then the character.
|
||||
// read double 5x, character 4x. "fencepost problem?"
|
||||
currentValue = readDoubleFromFile();
|
||||
for(incrementerRow = 0; incrementerRow < TAX_TABLE_R_COUNT; incrementerRow++)
|
||||
for(incrementerRow = 0; incrementerRow < TAX_TABLE_R_COUNT;
|
||||
incrementerRow++)
|
||||
{
|
||||
for(incrementerCol = 0; incrementerCol < TAX_TABLE_C_COUNT; incrementerCol++)
|
||||
for(incrementerCol = 0; incrementerCol < TAX_TABLE_C_COUNT;
|
||||
incrementerCol++)
|
||||
{
|
||||
if (incrementerCol == COLUMN_E)
|
||||
{
|
||||
taxDataArray[incrementerRow][incrementerCol] = currentValue;
|
||||
// printf("part working, %d, %d, %f\n", incrementerRow, incrementerCol, currentValue); // debug
|
||||
// printf("part working, %d, %d, %f\n",
|
||||
// incrementerRow, incrementerCol, currentValue); // debug
|
||||
currentValue = readDoubleFromFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
readCharacterFromFile();
|
||||
taxDataArray[incrementerRow][incrementerCol] = currentValue;
|
||||
// printf("part working, %d, %d, %f\n", incrementerRow, incrementerCol, currentValue); // debug
|
||||
// printf("part working, %d, %d, %f\n",
|
||||
// incrementerRow, incrementerCol, currentValue); // debug
|
||||
currentValue = readDoubleFromFile();
|
||||
}
|
||||
}
|
||||
|
|
@ -308,7 +313,8 @@ Device Input/Keyboard: none
|
|||
Device Output/Monitor: iteratively prints table as shown in examples
|
||||
Dependencies: printCharacter, printDoubleJustified, printf
|
||||
*/
|
||||
void displayCorrectTable(double taxDataArray[TAX_TABLE_R_COUNT][TAX_TABLE_C_COUNT])
|
||||
void displayCorrectTable(double
|
||||
taxDataArray[TAX_TABLE_R_COUNT][TAX_TABLE_C_COUNT])
|
||||
{
|
||||
// initialize variables
|
||||
int rowIndex, colIndex;
|
||||
|
|
@ -316,7 +322,7 @@ void displayCorrectTable(double taxDataArray[TAX_TABLE_R_COUNT][TAX_TABLE_C_COUN
|
|||
// get user input
|
||||
// input passed in through parameters.
|
||||
|
||||
// do calculations/display results, loop, use the below as the template for what each iteration does.
|
||||
// do calculations/display results, loop.
|
||||
for (rowIndex = 0; rowIndex < TAX_TABLE_R_COUNT; rowIndex++)
|
||||
{
|
||||
for (colIndex = 0; colIndex < TAX_TABLE_C_COUNT; colIndex++)
|
||||
|
|
@ -375,9 +381,12 @@ double calculateTax(double taxDataArray[TAX_TABLE_R_COUNT][TAX_TABLE_C_COUNT],
|
|||
// check to see where total income falls to figure out what rate to use.
|
||||
for (rowValue = 0; rowValue < TAX_TABLE_R_COUNT; rowValue++)
|
||||
{
|
||||
if ((totalIncome >= taxDataArray[rowValue][COLUMN_A]) || (taxDataArray[rowValue][COLUMN_B] <= totalIncome))
|
||||
if ((totalIncome >= taxDataArray[rowValue][COLUMN_A]) ||
|
||||
(taxDataArray[rowValue][COLUMN_B] <= totalIncome))
|
||||
{
|
||||
totalTax = ((totalIncome + taxDataArray[rowValue][COLUMN_C]) * taxDataArray[rowValue][COLUMN_D] * PERCENT_CONVERSION) + taxDataArray[rowValue][COLUMN_E];
|
||||
totalTax = ((totalIncome + taxDataArray[rowValue][COLUMN_C]) *
|
||||
taxDataArray[rowValue][COLUMN_D] * PERCENT_CONVERSION) +
|
||||
taxDataArray[rowValue][COLUMN_E];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue