# Answer to Question #55527 in C++ for Justice

Question #55527

Write a program that accepts the unit weight of a bag of coffee in pounds and the number of bags sold and displays the number of bags sold, the weight per bag, price per pound, sales tax and total price of the sale. the unit price of a bag of coffee is value as $5.99 per pound and tax rate of 7.25 percent.

Expert's answer

#include <iostream>

#include <string>

using namespace std;

int main(){

//variable for the unit weight of a bag of coffee in pounds

float unitWeight;

//variable for the number of bags sold

int numberBagsSold=0;

float salesTax;

//promt user to enter the unit weight of a bag of coffee in pounds

cout<<"Enter the unit weight of a bag of coffee in pounds: ";

cin>>unitWeight;

//promt user to enter the number of bags sold

cout<<"Enter the the number of bags sold: ";

cin>>numberBagsSold;

//the unit price of a bag of coffee is value as $5.99 per pound and tax rate of 7.25 percent.

//display the number of bags sold,

cout<<"\nThe number of bags sold: "<<numberBagsSold<<"\n";

//display the weight per bag

cout<<"The weight per bag "<<unitWeight<<"\n";

//display price per pound

cout<<"Price per pound: $5.99\n";

//display sales tax

float subTotal=numberBagsSold*unitWeight*5.99;

salesTax=0.0725*subTotal;

float totalPrice=subTotal+salesTax;

cout<<"Sales tax: $"<<salesTax<<"\n";

//display total price of the sale.

cout<<"Total price of the sale: $"<<totalPrice<<"\n";

//delay

system("pause");

return 0;

}

#include <string>

using namespace std;

int main(){

//variable for the unit weight of a bag of coffee in pounds

float unitWeight;

//variable for the number of bags sold

int numberBagsSold=0;

float salesTax;

//promt user to enter the unit weight of a bag of coffee in pounds

cout<<"Enter the unit weight of a bag of coffee in pounds: ";

cin>>unitWeight;

//promt user to enter the number of bags sold

cout<<"Enter the the number of bags sold: ";

cin>>numberBagsSold;

//the unit price of a bag of coffee is value as $5.99 per pound and tax rate of 7.25 percent.

//display the number of bags sold,

cout<<"\nThe number of bags sold: "<<numberBagsSold<<"\n";

//display the weight per bag

cout<<"The weight per bag "<<unitWeight<<"\n";

//display price per pound

cout<<"Price per pound: $5.99\n";

//display sales tax

float subTotal=numberBagsSold*unitWeight*5.99;

salesTax=0.0725*subTotal;

float totalPrice=subTotal+salesTax;

cout<<"Sales tax: $"<<salesTax<<"\n";

//display total price of the sale.

cout<<"Total price of the sale: $"<<totalPrice<<"\n";

//delay

system("pause");

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment