Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- // Total number of items
- int numItems(int totalItems[]) {
- int sum = 0;
- for (int i = 0; i < 4; i++) {
- sum += totalItems[i];
- }
- return sum;
- }
- //Average Profit / Total Profit
- double Avgprofit(int item_id[], double buying_price[], double selling_price[], double storage_fee[]) {
- double Total_profit = 0.0;
- int itemsTotal = 0;
- for (int i = 0; i < 4; i++) {
- Total_profit += item_id[i] * (selling_price[i] - (buying_price[i] + storage_fee[i]));
- itemsTotal += item_id[i];
- }
- return Total_profit / itemsTotal;
- }
- double Totalprofit(int num_items[], double buying_price[], double selling_price[], double storage_fee[], int item_id[]) {
- double profitTotal = 0.0;
- for (int i = 0; i < 4; i++) {
- profitTotal += num_items[i] * (selling_price[i] - (buying_price[i] + storage_fee[i]));
- }
- return profitTotal;
- }
- //Average Buying Price / Sum Buying Price
- double avgBuy(double buying_price[], int item_id[]) {
- double buyTotal = 0.0;
- int itemTotal = 0;
- for (int i = 0; i < 4; i++) {
- buyTotal += buying_price[i] * item_id[i];
- itemTotal += item_id[i];
- }
- return buyTotal / itemTotal;
- }
- //Average Selling Price / Sum Selling Price
- double avgSell(double selling_price[], int item_id[]) {
- double dollarsTotal = 0.0;
- double itemsTotal = 0.0;
- for (int i = 0; i < 4; i++) {
- dollarsTotal += selling_price[i] * item_id[i];
- itemsTotal += item_id[i];
- }
- return dollarsTotal / itemsTotal;
- }
- int main() {
- int item_id[4];
- int num_items[4];
- double buying_price[4];
- double selling_price[4];
- double storage_fee[4];
- char option = 'd';
- for (int i = 0; i < 4; i++) {
- cout << "Please enter Item ID, Number of Items, Buying Price, Selling price, and Storage fees for Item: " << i + 1 << endl;
- cin >> item_id[i] >> num_items[i] >> buying_price[i] >> selling_price[i] >> storage_fee[i];
- }
- while (option != 'c') {
- cout << "Please choose one of the following options:" << endl;
- cout << "Option a: Print stock information" << endl;
- cout << "Option b: Print general information" << endl;
- cout << "Option c: Exit" << endl;
- cout << "Option: ";
- cin >> option;
- if (option == 'a') {
- for (int i = 0; i < 4; i++) {
- cout << "* Item Id: " << item_id[i] << endl;
- if (num_items[i] < 25) {
- cout << "* Number of Items: " << num_items[i] << " (Need more)" << endl;
- }
- else if (num_items[i] >= 25) {
- cout << "* Number of Items: " << num_items[i] << endl;
- }
- cout << "* Buying Price: " << setprecision(4) << "$" << buying_price[i] << endl;
- cout << "* Selling Price: " << setprecision(4) << "$" << selling_price[i] << endl;
- cout << "* Storage Fees: " << setprecision(4) << "$" << storage_fee[i] << endl;
- cout << "* Profit: " << setprecision(4) << "$" << num_items[i] * (selling_price[i] - (buying_price[i] + storage_fee[i])) << endl;
- }
- }
- if (option == 'b') {
- cout << "* Total Number of Items: " << numItems(num_items) << endl;
- cout << "* Total Profit: " << setprecision(4) << "$" << Totalprofit(num_items, buying_price, selling_price, storage_fee, item_id) << endl;
- cout << "* Average Profit: " << setprecision(4) << "$" << Avgprofit(item_id, buying_price, selling_price, storage_fee) << endl;
- cout << "* Average Buying Price: " << setprecision(4) << "$" << avgBuy(buying_price, item_id) << endl;
- cout << "* Average Selling Price: " << setprecision(4) << "$" << avgSell(selling_price, item_id) << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement