using c++ write a program that accepts the unit weight of a bag of coffee in pounds and the number of bags sold and display the number of bags sold ,the weight per bag price per pound sales tax and total price of the sale.the unit of a bag of coffee is valued as $5.99 pound and tax rate of 7.25 percent

Anwer

Certainly! Here's an example program written in C++ that takes the unit weight of a bag of coffee in pounds and the number of bags sold, and then calculates and displays the relevant information:

```cpp
#include <iostream>

int main() {
// Constants
const double UNIT_PRICE = 5.99; // Price per pound
const double SALES_TAX_RATE = 0.0725; // 7.25% sales tax rate

// Variables
double weightPerBag, totalPrice, totalPriceWithTax;
int numBags;

// Accept user input for weight per bag and number of bags
std::cout << "Enter the weight per bag of coffee (in pounds): ";
std::cin >> weightPerBag;
std::cout << "Enter the number of bags sold: ";
std::cin >> numBags;

// Calculate the total price and total price with tax
totalPrice = weightPerBag * numBags * UNIT_PRICE;
totalPriceWithTax = totalPrice + (totalPrice * SALES_TAX_RATE);

// Display the results
std::cout << "\nNumber of bags sold: " << numBags << std::endl;
std::cout << "Weight per bag: " << weightPerBag << " pounds" << std::endl;
std::cout << "Price per pound: $" << UNIT_PRICE << std::endl;
std::cout << "Sales tax rate: " << (SALES_TAX_RATE * 100) << "%" << std::endl;
std::cout << "Total price (before tax): $" << totalPrice << std::endl;
std::cout << "Total price (after tax): $" << totalPriceWithTax << std::endl;

return 0;
}
```

To compile and run the program, follow these steps:

1. Open a C++ compiler and create a new source code file (.cpp) with the name of your choice (e.g., "coffee_sales.cpp").
2. Copy the above code and paste it into the created source file.
3. Save the file.
4. Compile the code using the C++ compiler. This process varies depending on the compiler you're using. For example, if you're using the GNU Compiler Collection (g++), you can compile the code by executing the following command in the terminal:
```
g++ coffee_sales.cpp -o coffee_sales
```
5. If the compilation is successful, an executable file (e.g., "coffee_sales" or "coffee_sales.exe") will be generated.
6. Run the program by executing the following command in the terminal:
```
./coffee_sales
```
7. Follow the prompts to enter the weight per bag and the number of bags sold.
8. The program will display the calculated results, including the number of bags sold, weight per bag, price per pound, sales tax rate, total price before tax, and total price after tax.