PLEASE HELP ASAP write this program in C Please try to make
PLEASE HELP ASAP!!!! write this program in C++. Please try to make it simple, this is just an intro class and going further or making certain coding shortcuts will confuse me. (I\'m pretty sure this program makes use of do while, if statements, else if statments, void functions, etc...)
---------------------------------------------------------------------------------------------------------------------------------
Write a program that prompts the user for the number of items purchased. If no items were purchased, the program should terminate after printing an appropriate message to the screen; otherwise, the program should repeatedly prompt the user for the price of the specified number of items and should calculate the total of all purchased items. The program should then calculate the shipping charge, the discounted totalafter a 20% discount, the tax on the discounted total, and the total amount due
After all calculations are performed, the program should print the author’s identifying information followed by the total of all purchased items, the discounted total, the tax rate, the tax on the discounted total, shipping charge and the total amount due. Output should be written in receipt form to both a file and to the console as shown below. File output should be directed to prog4_001out.txt.
You must use named constants to represent the amount of discount (20%), the cut off amount for free shipping ($150.00), shipping charge for totals less than $150.00 ($8.50) and for the tax rate (8.25%). The input values used for this program in order are: 15.50, 29.95, 19.99 (this is the part i\'m most confused by).
1. Prompt the user for the number of items purchased.
Read the number of items purchased.
2. If no items are purchased,
a. Print “Come back again soon!” (not bold and without the quotation marks) to the console
otherwise, (Items are purchased.)
a. Repeatedly prompt the user for the price of the next item purchased, and keep a running total of all prices entered.
(Hint: Since the program will ‘know’ how many times to prompt the user for a price, (based on the number of items purchased entered from above), for full credit, a count loop should be used to total the prices of all purchased items.)
b. Calculate the discounted total (total amount of all purchases after a 20% discount.)
c. Calculate the shipping charge based on the following:
If the total amount of all purchases after the discount is applied is $150.00 or more,
shipping is free;
otherwise,
shipping is $8.50.
d. Calculate the tax on the discounted total.
e. Calculate the amount owed by the customer. (discounted total + shipping + tax)
f. Print receipt - output to a file. (See notes below.)
g. Print receipt - output to the console. (See notes below.)
For file output, the author’s identifying information should be displayed starting in the top, left corner of the output file. Leave one blank line after the author’s identifying information before printing the receipt information to the output file as shown below.
For console output, leave two blank lines after the last value entered at the keyboard by the user before printing the author’s identifying information. Leave one blank line after the author’s
identifying information and before printing the receipt information as shown in the sample below. Leave two blank lines after the receipt information before printing an appropriate message informing the user that a copy for his/her records can be found in prog4_001out.txt. See sample below.
---------------------------------------------------------------------------------------------------------------------------------
the outputs are supposed to look like this:
Sample Console UUutput Enter the nunber of itens purchased: 3 Input for the final run you submit Enter the item price 18.95 Enter the item price 15.50 Enter the item price 12.00 instructions to the \'user. may differ -List authors\' names here Author\'s Nane C.S.1428. Lab Section: L? Replace question mark with lecture section number Replace question mark with lab section number -Due date (in this format.) Total Purchases46.45 Discounted Total: Tax Rate: Tax: Shipping: 34.84 0.0825 2.87 8.50 program\'s output Total Anount Due S46.21 A copy for your records can be found in prog4 00?out.txt Note where the cursor lands Your output file name(s) will differ Sample File Output: X prog4 out.txt × +--Your file name will be different. Author\'s Name C.S.1428. Lab Section: L? List authors names here Replace question mark with lecture section number. Replace question mark with lab section number. Due date (in this format.) S 46.45 34.84 Total Purchases: Discounted Total: Tax Rate: Tax: Shipping: 0.0825 2.87 8.50 Output values will vary depending on input values& values for named constants Total Amount Due:$46.21Solution
#include<iostream>
#include<fstream>
#include<iomanip>
#define MAX 1000
using namespace std;
const double DISCOUNT = 0.2;
const double TAX = 8.25/100;
double shipping = 8.50;
int main()
{
ofstream outfile; // output file prog4_001out.txt
int n ; //no of items purchased
double price_items[MAX],sum=0,dis_total=0,fina_total=0,dis_total1=0,dis,tax; //price of n items
outfile.open(\"prog4_001out.txt\");
if( outfile.fail())
{
cout<<\"Cant open file \"<<endl;
exit(1);
}
cout<<\"Enyter the number of items purchased: \";
cin>>n;
if( n == 0 )
{
cout<<\"Come back again soon!\"<<endl;
exit(0);
}
int i = 1;
int j=0;
int cnt = n;
while(n)
{
cout<<\"Enter item \"<<i<<\" :\";
cin>>price_items[j];
i++;
--n;
j++;
}
//calculate total sum
for(int i = 0; i < cnt ; i++ )
{
sum+=price_items[i];
}
cout<<setprecision (3);
dis = sum * DISCOUNT ; //calculate discout price
dis_total= sum - dis; // amount after deducting discount from sum
// apply shipping rate of 8.50 if sum less than 150
if( dis_total < 150 )
{
dis_total1 = (8.50);
}
else
dis_total1 = 0;
//tax on sum
tax = dis_total * TAX;
//calculate total sum after adding tax and shipping
fina_total= dis_total + tax + dis_total1;
cout<<\"Author\'s Name\"<<endl;
cout<<\"C.S.1428.?\" <<endl; // \'?\' represents author\'s lecture section #
cout<<\"Lab Section: L? \" <<endl; // \'?\' represents student\'s lab section #
cout<<\"--/--/-- \" <<endl; // dashes represent due date, month/day/year
cout<<\"Total Purchases: $ \"<<sum<<endl;
cout<<\"Discounted Total: \"<<dis_total<<endl;
cout<<\"Tax Rate: \"<<TAX<<endl;
cout<<\"Tax: \"<<dis_total * TAX<<endl;
cout<<\"Shipping: \"<<dis_total1<<endl;
cout<<\"Total Amount Due: $ \"<< fina_total<<endl;
cout<<\"A copy for your records can be found in prog4_001out.txt.\"<<endl;
outfile<<\"Total Purchases: $ \"<<sum<<endl;
outfile<<\"Discounted Total: \"<<sum<<endl;
outfile<<\"Tax Rate: \"<<TAX<<endl;
outfile<<\"Tax: \"<<tax<<endl;
outfile<<\"Shipping: \"<<shipping<<endl;
outfile<<\"Total Amount Due: $ \"<< fina_total<<endl;
}


