• Home
  • Outdoor Adventure
    • Hiking
    • Backpacking
    • Camping
    • Caving
  • Travel
  • Life Style
    • Diploma Life
    • Degree Life
    • Work and Part Time
  • Code Test and Project
  • FYP

Jack Hau Story

facebook twitter instagram


Write a complete program


class Product {
private:
    int prodID;
protected:
    float total_price;
public:
    Product() { total_price = 0.0; }
    void input_prodID()
    {
        cout << "Enter product ID : ";
        cin >> prodID;
    }
    int get_prodID() { return prodID; }
};
class canFood : protected Product {
private:
    float unit_price;
    int order_unit;
public:
    void get_Product()
    {
        input_prodID();
        cout << "Enter price : ";
        cin >> unit_price;
        cout << "Enter order unit : ";
        cin >> order_unit;
        cout << endl;
    }
    void calculate_Total() { total_price = unit_price * order_unit; }
    void display_product()
    {
        cout << "\nProduct ID : " << get_prodID() << endl;
        cout << "Total price : " << total_price << endl;
    }
};
void main()
{
    int num, i;
    cout << "How many types of canned food? ";
    cin >> num;
    cout << endl;
    canFood* tp;
    tp = new canFood[num];
    for (i = 0; i < num; i++) {
        tp[i].get_Product();
        tp[i].calculate_Total();
    }
    for (i = 0; i < num; i++) {
        tp[i].display_product();
    }
    system("PAUSE");
} /* Marks are allocated based on overall correctness and students may choose any array pointer notations */
Share
Tweet
Pin
Share
No comments
Newer Posts
Older Posts

About me



Jack is a programmer, hiker who loves to take challages. Programming can be hard, but no pain no gain. Beside that, Jack like to use cooking for stress relief. “Cooking is a great destresser because it serves as a creative outlet”. During cooking the chef have to well handle of food ingredients. “Cooking is like giving birth because you are mixing things together to create something new and wonderful.”

Labels

Backpacking Camping car Caving Code Test and Project Degree Life Diploma Life Event FYP Hiking Mountain Internship MMU Cyberjaya MMU Melaka Outdoor Adventure Part Time and Work Penang Singapora Thailand Trip and Travel

recent posts

Follow Us

Blog Archive

  • ►  2018 (2)
    • ►  May (1)
    • ►  January (1)
  • ►  2017 (8)
    • ►  August (2)
    • ►  July (1)
    • ►  May (1)
    • ►  April (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (1)
  • ►  2016 (22)
    • ►  December (3)
    • ►  November (1)
    • ►  October (2)
    • ►  September (3)
    • ►  July (1)
    • ►  May (2)
    • ►  April (6)
    • ►  March (2)
    • ►  February (1)
    • ►  January (1)
  • ►  2015 (3)
    • ►  December (1)
    • ►  September (2)
  • ►  2014 (19)
    • ►  October (1)
    • ►  September (2)
    • ►  July (4)
    • ►  June (5)
    • ►  April (2)
    • ►  March (3)
    • ►  January (2)
  • ▼  2013 (10)
    • ►  December (2)
    • ►  November (1)
    • ►  October (1)
    • ▼  September (1)
      • Coding C++ Sample Final Exam Question
    • ►  August (3)
    • ►  June (2)
  • ►  2012 (4)
    • ►  September (1)
    • ►  June (2)
    • ►  February (1)
  • ►  2011 (2)
    • ►  December (1)
    • ►  August (1)
Powered by Blogger.