Write a program that asks for the number of units sold and computes the total cost of the purchase. Input validation: Make sure the number of units is greater than 0. Use output (stream) manipulators: 2 digits after the decimal point g

Respuesta :

Answer:

Explanation:

The following code is written in C++, it asks the user for input on number of units sold and places it in a variable called units_sold. Then it asks for the package price and places that value in a variable called package_price. Finally it multiplies both values together into a variable called final_price and adjusts the decimals.

#include <iostream>

#include <iomanip>

using namespace std;

       int main()

       {

       // Variables

       int units_sold,

       final_price;

       // ask user for number of units sold

       cout << "\nEnter number of units sold: ";

       cin >> units_sold;

       

       //ask for Package price

       cout << "\nEnter Package Price: ";

       cin >> package_price;

       // Total amount before discount

       final_price = units_sold * package_price;

       cout << setprecision(2) << fixed;

       cout << endl;

       return 0;

       }