Question

Write a program that uses the class productType

Please specify what goes in main.cpp, productType.h and productType.cpp

Please do not leave anything out, thank you!

Consider the definition of the following class: (1, 2,3, 5,7) class productType 8. //Line 1 //Line 2 //Line //Line 4 //Line5 public: productType () productType (int, double, double) productType (string, int, double, double) /Line 6 productType (string, string, string, int, double, double) //Line7 void set (string, string, string, int, double, double) //Line 8 //Line s void print) const; void setQuantitiesInstock (int x)i void updateQuantitiesInStock (int x)i int getQuantitiesInstock() const; //Line 10 //Line 11 //Line 12 void setPrice (double x); double getPrice() const; void setDiscount (double d)i double getDiscount ) const //Line 13 //Line 14 //Line 15 //Line 16 //Line 17 //Line 18 //Line 19 //Line 20 //Line 21 //Line 22 //Line 23 //Line 24 private: string productName; string id; string manufacturer; int quantitiesInStock; double price; double discount; J:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>

using namespace std;

int main()

{

    // create objects of class productType

    productType ob1;

    productType ob2(100, 122.2, 5);

    productType ob3( "Razor", 100, 122.2, 5 );

    productType ob4( "Battery" , "101", "Philips", 120, 13.6, 7 );

   

    // set the data values of ob1

    ob1.set( "Battery" , "101", "Philips", 120, 13.6, 7 );

   

    // print the values of objects

    ob1.print();

    ob2.print();

    ob3.print();

    ob4.print();

   

    cout<<"Quantities in stock : "<<ob1.getQuantitiesInStock()<<endl;

    cout<<"Price : $"<<ob1.getPrice()<<endl;

    cout<<"Discount : "<<ob1.getDiscount()<<endl;

   

    // update the values of object ob2

    ob2.setQuantitiesInStock(30);

    ob2.setPrice(36.2);

    ob2.setDiscount(9.3);

   

    cout<<"Quantities in stock : "<<ob2.getQuantitiesInStock()<<endl;

    cout<<"Price : $"<<ob2.getPrice()<<endl;

    cout<<"Discount : "<<ob2.getDiscount()<<endl;

   

    return 0;

}

Add a comment
Know the answer?
Add Answer to:
Write a program that uses the class productType Please specify what goes in main.cpp, productType.h and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Consider the definition of the following class: (1,2,3, 5,7 clasa productTyp publie productType O productType(int....

    C++ Consider the definition of the following class: (1,2,3, 5,7 clasa productTyp publie productType O productType(int. double, double) productType (atring, int, double, double)s //tine6 productType (atring. atring.atring //Line1 /Line 2 /Line 3 //Line /Line s int, double, double) //Line 7 void set (atring, atring, string. int void print) const double, double) i //Line //tine 9 void setQuantitiesInstock (int x) void updateQuantitiesinstock (int x) int getQuantitiesInstock) const //Line 10 //Line 11 //Line 12 void #etPrice (double x); double getPrice) consti //Line...

  • There are four syntax errors/incorrect statements in the following class definition. List the line numbers of...

    There are four syntax errors/incorrect statements in the following class definition. List the line numbers of the lines that contain errors, and then write the corrected line(s). (4 points) class jetType //Line 1 { //Line 2 public: //Line 3 void setValues(string, int, double); //Line 4 print() const; //Line 5 string getManufacturer() const; //Line 6 double getPrice() const; //Line 7 bool compareSeating(const jetType&); //Line 8 int jetType(); //Line 9 jetType(string); //Line 10 jetType(string, int, double); //Line 11 private; //Line 12 string...

  • 6. Suppose your program contains the following class definition. Please indicate whether the stat...

    6. Suppose your program contains the following class definition. Please indicate whether the statement (a)-(e) are valid. If any one is invalid, please explain why include <iostream» using atd:icout: uning stdrtendli class Auto publier void setPrice (doubleli void setProfit (doublel double getPrice) private t double price, profiti double getProfitO // The definitions of member functions are omitted. int main() Auto honda, toyota: double a, b 0 honda. setPrice (19999.99): 17 (a) toyota.price 19999.99 b) a toyota. setProfit (10.0) // (c)...

  • Below is a class definition (.h) for the Bookclass. class Book { private:     int numPages;     string...

    Below is a class definition (.h) for the Bookclass. class Book { private:     int numPages;     string author;     string isbn;     double price; public:     string title;      public:     Book ();     void setAuthor(string);     string getAuthor();     void setIsbn(string);     string getIsbn ();     void setPrice(double);     double getPrice ();     string getTitle (); };                Assume you are writing code within the maindriver program: declare variable of type Book. Using the Bookvariable, set your book’s author to Edgar Allan Poe Using the Bookvariable, set your book’s title to The...

  • This is for my c++ class and I would really appreciate the help, Thank you! Complete...

    This is for my c++ class and I would really appreciate the help, Thank you! Complete the definitions of the functions for the ConcessionStand class in the ConcessionStand.cpp file. The class definition and function prototypes are in the provided ConcessionStand.h header file. A testing program is in the provided main.cpp file. You don’t need to change anything in ConcessionStand.h or main.cpp, unless you want to play with different options in the main.cpp program. ___________________ Main.cpp ____________________ #include "ConcessionStand.h" #include <iostream>...

  • USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds...

    USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds data about an item in a retail store. The class should have the following member variables: description: A string that holds a brief description of the item. unitsOnHand: An int that holds thw number of units currently in inventory. price: A double that holds that item's retail price. Write the following functions: -appropriate mutator functions -appropriate accessor functions - a default constructor that sets:...

  • This is a simple C++ class using inheritance, I have trouble getting the program to work....

    This is a simple C++ class using inheritance, I have trouble getting the program to work. I would also like to add ENUM function to the class TeachingAssistant(Derived class) which is a subclass of Student(Derived Class) which is also a subclass of CourseMember(Base Class). The TeachingAssistant class uses an enum (a user-defined data type) to keep track of the specific role the TA has: enum ta_role {LAB_ASSISTANT, LECTURE_ASSISTANT, BOTH}; You may assume for initialization purposes that the default role is...

  • CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer;...

    CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...

  • Make an abstract class Number that allows the rest of the code to work correctly. printDoubled...

    Make an abstract class Number that allows the rest of the code to work correctly. printDoubled should be able to take either an Int or a Double and print out twice its value. #include <iostream> using namespace std; //Do not modify anything on or above the line below this //YOUR_CODE_BELOW //YOUR_CODE //YOUR_CODE_ABOVE //Do not modify anything on or below the line above this void printDoubled(const Number& n) { cout << n.getValue() * 2 << endl; } class Int : public...

  • C++ Practice: Answer Whichever you can & it'll help a lot. Thank you! Question 1. Implement...

    C++ Practice: Answer Whichever you can & it'll help a lot. Thank you! Question 1. Implement the constructors and member function of each of the classes (Marks 15) class Fraction{ private: int numerator; int denominator; public: Fraction(int, int); float fractionValue();//determines the value of numerator/denominator }; class Problem{ private: Fraction f[3]; public: Problem(int, int, int, int, int, int); Fraction largestFraction();//Returns the fraction having largest fraction value }; Question 2: In the following Inheritance problem #include<iostream> #include<string> using namespace std; class Animal{...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT