Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(C++) Plan and code a program utilizing one file for input and one file for outp

ID: 3816082 • Letter: #

Question

(C++)Plan and code a program utilizing one file for input and one file for output 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 perperson, 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 costof 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.5percent; 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.00

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, totalfood 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.

Explanation / Answer

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
int i,j;
int const row=6;
int const col=4;
int const numbers_per_line=5;
double num,highest, lowest,sum,average;  
double partial_sum = 0;
while ( std::getline( infile, line ) )
{
if ( line.erase( 0, s.find_first_not_of( " ", 0) ).empty() ) continue;
std::istringstream( line ) is;
int lowest = 0, highest = 0;
int sum = 0, average = 0;
size_t count = 0;
int number = 0;
while ( is >> number )
{
if ( count == 0 )
{
lowest = highest = number;
}
else if ( number < lowest )
{
lowest = number;
}
else if ( highest < number )
{
highest = numbber;
}
count++; sum += number;
}
if ( count != 0 ) average = sum / count;
}