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

Create a program that will calculate and print to the screen a sales receipt. +

ID: 3891416 • Letter: C

Question

Create a program that will calculate and print to the screen a sales receipt. + Required:* 1. First 3 lines of code will be three comment lines a. Name of the cpp file b. Your name c. Why you are doing this program- 2. The user will enter in the number of sales items 3. The user will enter in the price for each item 4. The user will enter in the sales tax percentage- 5. Output a. Title for the output ount have 2 decimal point places c. Money amount to be aligned d. Boarder around the output 6. The user will have the ability to run this program again. The figure below should be used as an EXAMPLE and you should follow the format of the receipt. "C:Users jlongDesktoplHhcpplDebugthw.exe" ow many sales items do you have3 nter in the value of sales item 1 : $10 nter in the value of sales item 2 : 510 nter in the value of sales item 3 : $10 nter in the sales tax percentage Enter 10 for 10%): 6 Total Sales Sales tax 30.00 1.80 Grand Total 31.80 o you want to run this program again? :

Explanation / Answer

Source Code:

#include <iostream>


#include <string>
#include <vector>
#include <iomanip>
void func();
using namespace std;

int main( )
{
char ch;
func(); // main program
while(true){ //runs untill you press 'N'
cout<<"Do you want to run this program again? <Y/N>";
cin>>ch;
switch(ch){
case 'Y': func();
break;
case 'N': return 0;
}
}

return 0;
}
void func()
{

int n=0,i;
float item[n],per_item[n];
float per=0,tot_per=0,tot_amount=0,grand_total=0;
cout<<"How many sales items do you have?";
cin>>n;
for(i=0;i<n;i++){
cout<<"Enter the price of Item "<<(i+1)<<": ";
cin>>item[i];
}
cout<<"Enter the sales tax percentage <Enter 10 for 10%> :";
cin>>per;
for(i=0;i<n;i++){
per_item[i]=item[i]*per/100;
}
for(i=0;i<n;i++){
tot_per+=per_item[i];
tot_amount+=item[i];
}
grand_total=tot_per+tot_amount;
cout<<"";
  
cout << std::setfill( '*' ) << setw( 45 ) << '*' << endl;
cout << "*************" << std::right << setfill(' ' )<< setw(45-30) << "SALES RECEIPT" <<setfill(' ' )<< setw(45-28) <<"***************"<< endl;
cout << std::setfill( '*' ) << setw( 45 ) << '*' << endl;
cout << "**" << std::left << setfill(' ' )<< setw( 45 - 4 ) << "" << "**"<< endl;
cout << "**" << std::left << setfill(' ' )<< setw( 45 - 4 ) << "" << "**"<< endl;

cout << "**" << std::left << setfill(' ' )<< setw( 45 - 22) << " Total Sales $ " <<std::left << setfill(' ' )<< setw( 45 - 37)<<std::fixed<<std::setprecision(2)<<tot_amount<<std::right << setfill(' ' )<< setw( 45 - 33)<< "**"<< endl;

cout << "**" << std::left << setfill(' ' )<< setw( 45 - 22 )<< " Sales Tax $ " <<std::left << setfill(' ' )<< setw( 45 - 37)<<std::fixed<<std::setprecision(2)<<tot_per<<std::right << setfill(' ' )<< setw( 45 - 33)<< "**"<< endl;
cout << "**" << std::right << setfill(' ' )<< setw( 45 - 22 ) << " -----" <<"---------"<< std::right << setfill(' ' )<< setw( 45 - 34 )<< "**"<< endl;
cout << "**" << std::left << setfill(' ' )<< setw( 45 - 22 ) << " Grand Total $ " <<std::left << setfill(' ' )<< setw( 45 - 37)<< std::fixed<<std::setprecision(2)<<grand_total<<std::right << setfill(' ' )<< setw( 45 - 33)<< "**"<< endl;

cout << "**" << std::left << setfill(' ' )<< setw( 45 - 4 ) << "" << "**"<< endl;
cout << std::setfill( '*' ) << setw( 45 ) << '*' << endl;
  

}

OUTPUT:

How many sales items do you have?3                                                                                               

Enter the price of Item 1: 10                                                                                                    

Enter the price of Item 2: 10                                                                                                    

Enter the price of Item 3: 10                                                                                                    

Enter the sales tax percentage                                                                                                   

<Enter 10 for 10%> :6                                                                                                           

*********************************************                                                                                    

*************  SALES RECEIPT  ***************                                                                                    

*********************************************                                                                                    

** **                                                                                    

** **                                                                                    

**   Total Sales       $ 30.00 **                                                                                    

**   Sales Tax         $ 1.80 **                                                                                    

**                  -------------- **                                                                                    

**    Grand Total      $ 31.80 **                                                                                    

** **                                                                                    

*********************************************                                                                                    

Do you want to run this program again? <Y/N>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote