are now looking todiversify your orders. Also, you and your friends have determi
ID: 3614144 • Letter: A
Question
are now looking todiversify your orders. Also, you and your friends have determinedit’s
faster for one personto order for everyone than for everyone to order separately.Thus,
each time you go,either you or one of your friends will put in severalorders.
To simplify thisproblem (as many restaurants do), each different pizza order willbe
given a number(starting from 0) and each of these orders will have a price.Your
program will read inthis information from a file named “pizza.txt” and thenuse it to
determine the pricesof different orders of pizza. The information for these orderswill
ALSO be in the file.The specifications for the file format are given below.
InputSpecification
1. The first line ofthe input file will contain a single positive integer,n (n <100),
specifying the numberof different pizza orders for Lazy Moon.
2. The nextn lines will each contain one positive real numberspecifying the price for that
corresponding pizza.(The first line will have the price for pizza 0, the next line forpizza
1, etc.)
3. The following linewill contain a single positive integer k (k <50) representing the
number of orders youhave to evaluate.
4. The nextk lines will contain information about each ofthe korders with one order per
line.
5. Each of these lineswill contain nnon-negative integers, representinghow many of
those pizzas,respectively are in the order. (For example, if n=5 and the linecontains the
values 0 0 6 0 9, thenthe order contains 6 slices of pizza #2 and 9 slices of pizza#4.)
OutputSpecification
For each of thek test cases, output a line with the followingformat:
On day X, you will spend$YY.YY at Lazy Moon.
whereX isthe test case number (starting with 1), and YY.YY is the price ofthe pizza
displayed with exactly2 digits after the decimal. (Note: The price may exceed100
dollars, so YY simplyrepresents a dollar amount and not the exact number of digitsin
that dollaramount.
Sample InputFile (pizza.txt)
5
3.00
3.50
4.50
5.00
6.00
3
1 1 1 1 1
0 0 2 1 6
1 0 3 2 3
Sample Output(Corresponding to Sample Input File)
On day 1, you will spend$22.00 at Lazy Moon.
On day 2, you will spend$50.00 at Lazy Moon.
Explanation / Answer
#include #include int main() {FILE *file; int i,n,k,j,num; double price[100],total; file = fopen("pizza.txt","r"); if(file==NULL) {printf("Error opening pizza.txt! "); getch(); return 0; } fscanf(file,"%d",&n); for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.