Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (kikuo):

Alright.

OpenStudy (kikuo):

Alright, I did an assignment recently. This was my original output. [code] //Ashton Dreiling //Monthly sales tax exercise #include <iostream> #include <stdlib.h> using namespace std; //module prototypes void calculateCountySalesTax(double &countyTax, double &monthySales); void calculateStateSalesTax(double &monthlySales, double &stateTax); //global constants to help with mathematical expressions const double STATE_SALES_TAX_RATE = 0.04; const double COUNTY_SALES_TAX = 0.02; int main() { //some variables double monthlySales; double countyTax; double stateTax; double totalSalesTax; cout << "Today we are going to be calculating your total sales tax."<< endl; cout << "Please enter your total monthly sales." << endl; cin >> monthlySales; cout << "You put that your monthly sales are " << monthlySales << endl; cout << "We will now calculate your county sales tax." << endl; //moving to module calculateCountySalesTax calculateCountySalesTax(countyTax, monthlySales); cout << "Your county sales tax is $" << countyTax << endl; cout << "We will now calculate your state sales tax." << endl ; //moving to module calculateStateSalesTax calculateStateSalesTax(monthlySales, stateTax); cout << "Your state sales tax is $" << stateTax << endl; cout << "Now, give us a minute to calculate your total." << endl; //total sales tax totalSalesTax = stateTax + countyTax; cout << "Your total sales tax is $" << totalSalesTax << endl; system("Pause"); return 0; }//end main void calculateCountySalesTax(double &countyTax, double &monthlySales) { countyTax = monthlySales + COUNTY_SALES_TAX; }//end calculateCountySalesTax void calculateStateSalesTax(double &monthlySales, double &stateTax) { stateTax = monthlySales * STATE_SALES_TAX_RATE; }//end calculateStateSalesTax [/code] This is my instructors code. [code]// Chapter 3 Programming Exercise: 10 // Ray Warren // 25 May 2013 // 14 Sept 2013 rewrite with reference parameters to return results #include <iostream> #include <cstdlib> using namespace std; // Function prototypes // NOTICE: the use of reference parameters to return results void getUserInput(double &myTotalMonthlySales); void calcCountyTax(double myTotalMonthlySales, double &myCountyTax); void calcStateTax(double myTotalMonthlySales, double &myStateTax); void displayResults(double myCountyTax, double myStateTax); // global CONSTANTS const double COUNTY_TAX = 0.02; // County sales tax rate const double STATE_TAX = 0.04; // State sales tax rate int main() { double totalMonthlySales = 0; // the user supplied total monthly sales double countyTax = 0; // the county sales tax double stateTax = 0; // the state sales tax // (INPUT) get the total monthly sales from the user getUserInput(totalMonthlySales); // (PROCESS) calculate the tax components calcCountyTax(totalMonthlySales, countyTax); calcStateTax(totalMonthlySales, stateTax); // (OUTPUT) display the results displayResults(countyTax, stateTax); system("Pause"); return 0; } // end main() void getUserInput(double &myTotalMonthlySales) { // get the total monthly sales from the user cout << "Enter the total monthly sales." << endl; cin >> myTotalMonthlySales; } // end getUserInput() void calcCountyTax(double myTotalMonthlySales, double &myCountyTax) { // calculate the tax - return the result through reference myCountyTax = myTotalMonthlySales * COUNTY_TAX; } // end calcCountyTax() void calcStateTax(double myTotalMonthlySales, double &myStateTax) { // calculate the tax - return the result through reference myStateTax = myTotalMonthlySales * STATE_TAX; } // end calcStateTax() void displayResults(double myCountyTax, double myStateTax) { // display the results cout << "County tax: $" << myCountyTax << endl; cout << "State tax: $" << myStateTax << endl; cout << "Total sales tax: $" << (myCountyTax + myStateTax) << endl; } // end displayResults()[/code] I know based off of his notes that I made two mistakes. : countyTax = monthlySales * COUNTY_SALES_TAX; and const double STATE_SALES_TAX_RATE = 0.04; const double COUNTY_SALES_TAX = 0.02; If I put those in would that fix the problems I made and therefore would have given me 100%?

OpenStudy (kikuo):

@Sachintha

OpenStudy (sachintha):

Your code seems right for me. He might have reduced your marks due to the way you have used reference parameters which is not what he might have intended.

OpenStudy (kikuo):

@Sachintha If you read what I said at the bottom I tell you why he reduced points haha. (x I put his code in there as well so you can confirm it. : )

OpenStudy (sachintha):

Yeah you are correct. I didn't notice that earlier. :3 You could have taken 100% by correcting them. :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!