Computer Science, asked by abdulvahidm, 9 months ago

1
Write a C++ program to input the amount of sales for 12 months into an
array named Sales Amt. After all the input, find the total and average amount
of sales​

Answers

Answered by Anonymous
5

Explanation:

Write a C++ program that accepts sales unit price and sales quantity of various items and compute total sales amount and the average sales quantity. All input values must greater than or equal to 0 and less than or equal to 1,000, and the number of pairs of sales unit and sales quantity does not exceed 100. If a fraction occurs in the average of the sales quantity, round the first decimal place.

Sample Solution:

C++ Code :

#include <iostream>

using namespace std;

int main()

{

int sale_price, qty, ctr = 0, sum1 = 0, sum2 = 0;

cout << "Input Sales Price and Sales Quantity: ";

while (cin >> sale_price >> qty)

{

sum1 += sale_price * qty;

sum2 += qty;

ctr++;

}

cout << "\nTotal of the sales amount and the average of the sales quantity:\n";

cout << sum1 << endl << static_cast<int>(static_cast<double>(sum2) / ctr + 0.5) << endl;

return 0;

}

MARK ME AS BRAINLEIST PLS BRO

HOPE IT'S HELPFUL

GOD BLESS ALL

Similar questions