AT&T; ? 11:49 PM * 90% ( D, + Lab Quiz Two Soda Sales Report.txt Design a progra
ID: 3891103 • Letter: A
Question
AT&T; ? 11:49 PM * 90% ( D, + Lab Quiz Two Soda Sales Report.txt Design a program as per the following information using the accompanying data file sodaSales.dat Make sure the program compiles and that you include pseudo code. The quiz is worth 110 points You have been asked to produce the report below. Each month the company delivers 150 bottles to each location. This report will tell the company how Sales are going. You will read the file named soda sales The values are the brand name, number sold, the cost per bottle, the retail price Soda Sales Bottles Cost Ret Profit Percent Soda Sold Bottle Bottle Bottle Sold of 150 Totals The total will tell the company the number of bottles the average price, the total profit and the percentage sold, the average cost of all bottles sold Dashboard Calendar To Do Notifications InboxExplanation / Answer
If you have any doubts, please give me comment..
Language: C++
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
#include<cstdlib>
using namespace std;
struct SodaSales{
string brand_name;
int number_sold;
double cost;
double retail;
};
int main(){
SodaSales *sales = new SodaSales[100];
ifstream in;
in.open("SodaSales.dat");
if(in.fail()){
cout<<"Unable to open file."<<endl;
exit(1);
}
int i=0;
while(!in.eof()){
in>>sales[i].brand_name>>sales[i].number_sold>>sales[i].cost>>sales[i].retail;
i++;
}
cout<<"Successfully "<<i<<" read from file"<<endl;
cout<<setprecision(2)<<fixed;
cout<<" Soda Sales"<<endl;
cout<<"Soda Bottles Cost Retail Profit Percent"<<endl;
cout<<"--------------------------------------------------------------"<<endl;
double profit(0.0), avg_cost(0.0), avg_price(0.0), tot_profit(0.0);
int tot_bottles = 0;
for(int j=0; j<i; j++){
profit = (sales[i].number_sold * sales[i].cost) - (sales[i].number_sold * sales[i].retail);
tot_bottles += sales[i].number_sold;
avg_cost += sales[i].cost;
avg_price += sales[i].retail;
tot_profit += profit;
cout<<sales[i].brand_name<<" "<<sales[i].number_sold<<" "<<sales[i].cost<<" "<<sales[i].retail<<" "<<profit<<" "<<((sales[i].number_sold/150)*100)<<endl;
}
avg_cost /= i;
avg_price /= i;
cout<<"Totals "<<tot_bottles<<" "<<avg_cost<<" "<<avg_price<<" "<<tot_profit<<" "<<((tot_bottles/(150*i))/100)<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.