-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsales_data.cpp
More file actions
25 lines (25 loc) · 782 Bytes
/
sales_data.cpp
File metadata and controls
25 lines (25 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <ostream>
#include "Sales_data.h"
using namespace std;
int main()
{
Sales_data data1, data2;
cout << "Enter the price of the 2 books respectively:" << endl;
double price1=0.0, price2=0.0;
cin >> price1 >> price2;
cin >> data1.bookNo >> data1.units_sold >> price1;
data1.revenue = price1 * data1.units_sold;
cin >> data2.bookNo >> data2.units_sold >> price2;
data2.revenue = price2 * data2.units_sold;
if (data1.bookNo == data2.bookNo)
{
unsigned total_sold = data1.units_sold + data2.units_sold;
double total_revenue = data1.revenue + data2.revenue;
return total_revenue/total_sold;
}else
{
cerr << "Data must have the same book number" << endl;
return -1;
}
}