C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 10, Problem 8SA

Consider the definition of the following class: (1, 2, 3, 5, 7)

classproductType                                    //Line 1 {                                                             //Line 2 public:                                                   //Line 3 productType();                                      //Line 4 productType ( int, double, double ) ;       //Line 5 productType(string, int, double, double);//Line 6 productType(string, string, string, int, double, double);                                //Line 7 voidset(string, string, string, int, double, double);                                       //Line 8 voidprint()const;                                     //Line 9 voidsetQuantitiesInStock(intx);              //Line 10

void updateQuantitiesInStock (int x);                 //Line11 int getQuantitiesInStock () const;                       //Line12 void setPrice (doublex);                                   //Line13 doublegetPrice()const;                                   //Line14 voidsetDiscount(doubled);                            //Line15 doublegetDiscount()const;                           //Line16 private:                                                        //Line17 string productName;                                   //Line18 string id;                                                     //Line19 string manufacturer;                                  //Line20 int quantitiesInStock;                                //Line21 double price;                                             //Line22 double discount;                                        //Line23 };                                                               //Line24

  1. Give the line number containing the constructor that is executed in each of the following declarations.

    i . productType productl; ii . productType product2 ( "Microwave" , "M3562", "GeneralPool", 35, 175 .00, 0 .1); iii . productType product3  ( "D1290", 25, 375 .00, 0 .05 ) ; iv . productType product4 ( 10, 8 .50, 0 .2 ) ;

  2. Write the definition of the constructor in Line 4 so that the instance variables are initialized to “ “, “ “, “ “, 0, 0.0, and 0.0, respectively.

  3. Write the definition of the constructor in Line 5 so that the string instance variables are initialized to””, and the other instance variables are initialized according to the parameters. Instance variables quantitieslnStock, price, and discount must be nonnegative.

  4. Write the definition of the constructor in Line 6 so that the instance variables productName and manufacturer are initialized to the empty string, instance variable id is initialized according to the first parameter, and the remaining instance variables are initialized according to the last three parameters. Instance variables quantitieslnStock, price, and discount must be nonnegative.

  5. Write the definition of the constructor in Line 7 so that the instance variables are initialized according to the parameters. Instance variables quantitieslnStock, price, and discount must be nonnegative.

Blurred answer
Students have asked these similar questions
Activity No. Activity Time (weeks) Immediate Predecessors 1 Requirements collection 3 2 Requirements structuring 4 1 3 Process analysis 3 2 4 Data analysis 3 2 5 Logical design 50 3,4 6 Physical design 5 5 7 Implementation 6 6 c. Using the information from part b, prepare a network diagram. Identify the critical path.
Given the following Extended-BNF grammar of the basic mathematical expressions:  Show the derivation steps for the expression: ( 2 + 3 ) * 6 – 20 / ( 3 + 1 ) Draw the parsing tree of this expression. SEE IMAGE
Whentheuserenters!!,themostrecentcommandinthehistoryisexecuted.In the example above, if the user entered the command: Osh> !! The ‘ls -l’ command should be executed and echoed on user’s screen. The command should also be placed in the history buffer as the next command. Whentheuserentersasingle!followedbyanintegerN,theNthcommandin the history is executed. In the example above, if the user entered the command: Osh> ! 3 The ‘ps’ command should be executed and echoed on the user’s screen. The command should also be placed in the history buffer as the next command. Error handling: The program should also manage basic error handling. For example, if there are no commands in the history, entering !! should result in a message “No commands in history.” Also, if there is no command corresponding to the number entered with the single !, the program should output "No such command in history."
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY