67 058
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #44027 in C++ for ty

Question #44027
Write the main function that creates array of Product to store 5 objects of Product. Read
the cost and profit rate for each product from the user. For each product, display the cost,
the profit (using function profit defined in struct Product) and the selling price (cost +
profit) on screen.
#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;    } }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!