Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C++) Using VOID FUNCTIONS Plan and code a program utilizing one file for input, one file for output and one file for errors to solve

(C++) Using VOID FUNCTIONSPlan and code a program utilizing one file for input, one file for output and one file for errors to solve the following problem:

A. For adults, the deluxe meals will cost $25.80 per person and the standard meals will cost $21.75 per person, dessert included. Children's meals will cost 60 percent of adult meals. Everyone within a given party must be served the same meal type. B. All customers will be charged the same rate for tip and tax, currently 18 percent (applied only to the cost of the food). C. A surcharge, currently 7 percent, is added to the total bill if the catering is to be done on the weekend (Friday, Saturday, or Sunday). D. To induce customers to pay promptly, a discount is offered if payment is made within ten days. E. This discount depends on the amount of the total bill. If the bill is less than $100.00, the discount is 1.5 percent; if the bill is at least $100.00 but less than $400.00, the discount is 2.5 percent; if the bill is $400.00 or more, the discount is 3.5 percent. Input Number of adults, number of children, meal type (D, S) character indicating whether or not date is a weekend (Y/N), amount of any deposit. Create the data file below in text editor or Notepad. Data File 10 0 S Y 100.00 27 3 D Y 57.50 125 17 D N 0.00 4 0 S N 25.00 0 25 S Y 23.75 250 43 D N 500.00 0 0 D N 0.0 10 0 R Y 10.00 17 3 D R 15.00 5 0 D Y 275.00 -3 10 D Y 20.00 14 -1 S N 30.00 20 3 D Y -10.00 Output Output an itemized bill listing the number of adults, children, cost for adult meals, cost for children's meals, total food cost, surcharge (if appropriate), tax and tip, total cost of the party, deposit (if any), total balance due, amount of discount if bill is paid within ten days. Output error data to a separate error file.

MUST LOOK LIKE THIS:

# include # include using namespace std; void GetData (ifstream &, ofstream &, int &, int &, int &, int &, int &);

void CalcGPA (int, int, float&, int &, int &);

void SendData (ofstream &, int, int, int, float); int main ()

{

ifstream Infile;

ofstream Outfile, Errorfile;

int ID;int Units, Points, Count= 0, Total= 0, UnitError, PointsError;float gpa, overallGPA ; while ( ! Infile.eof ( ) ){ GetData (Infile, Errorfile, ID, Units, Points, UnitError, PointsError);

if(! UnitError && ! PointsError)

{ CalcGPA (Units, Points, gpa, Total, Count);SendData ( Outfile, ID, Units, Points, gpa); } // end if

} //end whilecout < 0) //Prevent division by zero overallGPA << float (Total) I Count;else

overallGPA = 0.0;

cout << Overall GPA for Pierce students << overallGPA << endl;return 0;

} //end function main/***************************************/void GetData (ifstream & Infile, ofstream & Errorfile, int & ID, int & Units, int & Points, int & UnitError, int &PointsError ){ Infile >> ID >> Units >> Points; //Get student data from InfileUnitError = Units < 0 || Units > 250; //Check for Units, Points errors

PointsError = Points < 0 II Points > 4 * Units;

if (UnitError) // Output invalid date to ErrorfileErrorfile <<"Units error in record: "<< ID << <

if (PointsError)

Errorfile <<"Points error in record: "<< ID << <

}/***************************************///Calculate student gpa; accumulate count of students processed and total GPAs void CalcGPA ( int Units, int Points, float & GPA, int & Count, int & Total){ if (Units == 0) //Check for division by 0

GPA=0.0;

else GPA = (float (Points) / Units);

Count++; //Count number of studentsTotal+= GPA; //Accumulate total for all GPAs} /***************************************/void SendData (ofstream & Outfile, int ID, int Units, int Points, float GPA ) //Output valid data toOutfile{ Outfile <

Outfile << Student information for ID Number: << ID << endl;Outfile << Completed units: << Units << endl; Outfile << Grade points earned: << Points << endl;Outfile << GPA: << GPA << endl;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions