Create a code in C++ that reads from the archive input.txt the daily sales of ev
ID: 3747750 • Letter: C
Question
Create a code in C++ that reads from the archive input.txt the daily sales of every n products of a company, created by every m sellers during the d days of a given month. After reading the data, the program must calculate and write the following: 1. Total of unities sold of each product in the month (output: name of the product, total of unities 2. Name of the product with the greatest number of unities sold during a given day (output: name 3. List of all the sellers with the number of unities sold of one given product in a specific day sold of the product) of the product, total of unities sold of the product) output: name of the seller, number of unities sold of the product) The program must use a 3D dynamic array: sales[numSellers][numProducts [numDays] It must also use classes, a 3D dynamic array to store objects of a class, separated compilation, menu, namespaces and the directive #ifndef-All outputs must be by screen and in the output archive output.txt. The program must verify that first letter of the first and last name of the seller must be in capital letter. In case of being in lower case, it must change it to capital. The format for the sellers name is Last Name(s) First_Name Initial_Second_Name. It should also validate all numeric data. When a data is invalid, the screen must show a correspondent error message and the data must NOT be stored in the 3D dynamic array of objects.Explanation / Answer
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
//declare variables
char region = ' ';
int dailySales1 = 0;
int dailySales2 = 0;
int dailySales3 = 0;
int totalSales = 0;
int totalRegSales = 0;
cout << "Enter region (N/S/E/W): ";
cin >> region;
do
{
// Get daily sales...
cout << "First daily sales amount for Region " << region << ": ";
cin >> dailySales1;
cout << "Next daily sales amount for Region " << region << ": ";
cin >> dailySales2;
cout << "Next daily sales amount for Region " << region << ": ";
cin >> dailySales3;
// Add our regional sales
totalRegSales = dailySales1 + dailySales2 + dailySales3;
// Display the sales made for that region....
cout << "Total sales for Region " << region << ": " << totalRegSales << " ";
totalSales += totalRegSales;
// And if our total sales is more than 0, then display it before
// asking for our next region.
if( totalSales > 0 ){
cout << " Total Sales at this point: " << totalSales << " ";
}
cout << "Enter region (N/S/E/W): ";
cin >> region;
}
while (region == 'N' || region == 'S' || region == 'E' || region == 'W');
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.