#include <iostream>
typedef struct {
double cost;
double profitRate;
double CalculateProfit () {
return cost* profitRate;
}
double CalculateSellingPrice() {
return CalculateProfit() + cost;
}
} Product;
int main() {
const int SIZE = 5;
Product* prod = new Product[SIZE];
std::cout <<"Enter cost and profit rate for 5 products.Profit rate is always smaller than 1." << std::endl;
for ( int i = 0; i < SIZE; i++ ) {
std::cout << "Enter data for product number " << i + 1 << std::endl;
std::cin >> prod[i].cost;
std::cin >> prod[i].profitRate;
}
for ( int i = 0; i < SIZE; i++ ) {
std::cout << "Product number " << i + 1 << std::endl;
std::cout << "Cost: " << prod[i].cost << "\n" << "Profit: " << prod[i].CalculateProfit() << "\n" << "Selling price: " << prod[i].CalculateSellingPrice() << std::endl << std::endl;
}
}
Comments
Leave a comment