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

Videos

Textbook Question
100%
Book Icon
Chapter 10, Problem 10SA

Consider the definition of the class product Type as given in Exercise 8.

Answer the following questions. (1, 2, 3, 5, 7)

  1. Write the definition of the function set so that instance variables are set according to the paramaters. Instance variables quantitieslnStock, price, and discount must be nonnegative.

  2. Write the definition of the function print to output the values of the instance variables.

  3. Write the definition of the function setQuantitiesInStock to set the value of the instance variable quantitiesInStock according to the parameter.

  4. Write the definition of the function updateQuantitiesInStock to update the value of instance variable quantitiesInStock by adding the value of the parameter.

  5. Write the definition of the function getQuantitiesInStock to return the value of instance variable quantitiesInStock.

  6. Write the definition of the function setPrice to set the value of the instance variable price according to the parameter.

  7. Write the definition of the function getPrice to return the value of the instance variable price.

  8. Write the definition of the function setDiscount to set the value of the instance variable discount according to the parameter.

  9. Write the definition of the function getDiscount to return the value of the instance variable discount.

Blurred answer
Students have asked these similar questions
SUBJECT: OOPPROGRAMMING LANGUAGE: C++ ALSO ADD SCREENSHOTS OF OUTPUT.   Write a class Distance to measure distance in meters and kilometers. The class should have appropriate constructors for initializing members to 0 as well as user provided values. The class should have display function to display the data members on screen.   Write another class Time to measure time in hours and minutes. The class should have appropriate constructors for initializing members to 0 as well as user provided values. The class should have display function to display the data members on screen.   Write another class which has appropriate functions for taking objects of the Distance class and Time class to store time and distance in a file.   Make the data members and functions in your program const where applicable
SUBJECT: OOPPROGRAMMING LANGUAGE: C++ ADD SS OF OUTPUT TOO.   Create a class Student with attributes StudentName, Enrollment, semester, section, course MarksObtained and Grade. Write appropriate constructors, get and set functions for data members. The data member grade is automatically calculated based on marks obtained out of 100 for each course.
Redo Programming Exercise 3 by overloading the operators as nonmembers of the class boxType. Write a test program that tests various operations on the class boxType. Reference:   Chapter 11 defined the class boxType by extending the definition of the class rectangleType. In this exercise, derive the class boxType from the class rectangleType, defined in Exercise 1, add the functions to overload the operators +,–, *, ==, !=, <=, <, >=, >, and pre- and post-increment and decrement operators as members of the class boxType. Also overload the operators << and >>. Overload the relational operators by considering the volume of the boxes. For example, two boxes are the same if they have the same volume. Write the definitions of the functions of the class boxType as defined above and then write a test program that tests various operations on the class.
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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY