هذا السوال:
Create product class. It contains name, price, discount percentage and price after discount as data members.
- Define a default constructor to initialize all data members.
- Define a member function that uses price and discount percentage to calculate and set the price after discount. Note that a member function can call another member function.
- Create a non member function displayInfo that receives the product from the main. Display all the object information and also print the price after discount.
- In the main let the user enters the product name, discount percentage and price. Next, set the product object with this information. Finally calculate the price after discount and call diaplyinfo().
محاولتى فى الحل:
#include<iostream>
using namespace std;
class price{
int pric;
int discount percentage;
int price after discount;
public:
price( int price, int discount percentage ,int price after discount ){
price-= discount percentage;
cout<<"Enter product price\n ";
cin>>price;
cout<<"Enter the discount percentage\n";
cin>>discount percentage;
cout"Displaying product information\n";
cout<<"Price"<<price;
cout<<"Discount Percentage "<<discount percentage;
cout<<"Price After discount "<<price after discount;
}
};
int main()
(int ID;
price p;
cout<<"Enter product ID\n";
cin>>ID;
p.price;
return 0;
)
