Variables should be private and the class functions public

Assignment Help C/C++ Programming
Reference no: EM13165284

Define a class named Inventory. The class inventory should be written in a header file name Inventory.hpp. The class consists of following variables and functions--

Variables:

  • itemNumber-an integer variable that stores the item's number
  • quantity-an integer variable that holds the quantity of the item onhand
  • cost--a double that holds the wholesale per unit cost of the item
  • totalCost--a double thta holds the total inventory cost of the item (quantity*cost)

Functions:

  • a default constructor that sets all the member variables to zero
  • setItemNumber--accepts an integer argument that is copied to item-Number membe rvariable
  • setQuantity-accepts an integer argument that is copied to quantity member variable
  • setCost--accepts a double argument this is copied to cost member variable
  • setTotalCost-calculates the total inventory cost for the item (quantity*cost) and stores the result in totalCost
  • getItemNumber-returns the value in variable itemNumber
  • getQuantity--returns the value in variable quantity
  • getCost--returns the value in variable cost
  • getTotalCost--returns the value in variable totalCost.

All the class variables should be private and the class functions public. The class functions should be implemented in a file Inventory.cpp which should be linked with the inventory.hpp file.

After being done with the class declaration, create a file named Inventory-Main.cpp where you need to write your main function. You need to link both Inventory.cpp and Inventory.hpp to this file. In the main function, create an object of Type Inventory. Prompt the user to enter a value for the variables itemNumber, quantity, and cost. Set the variables and calculate the total cost. Display the values of all the variables for the object using the get functions in the following format:

"The item number 1 has 12 quantity each having a cost of 1.5 unit with the total cost being 18 units"

Reference no: EM13165284

Questions Cloud

Literature plan : You have just been hired to teach at a new preschool. You will be teaching a class of 3-5 year olds. Your task is to create a research-based “Literature Program” which will include developmentally appropriate approaches to teaching and learning. Your..
Develop an approach that will automatically integrate error : Develop an approach that will automatically integrate error messages and a user help facility. That is, the system would automatically recognize the error type and provide a help window with suggestions for correcting it. Perform a reasonably complet..
Study of prosocial behavior : By-stander behavior is an important topic within the study of prosocial (helping) behavior. Apply the well-known and respected by-stander research of Latane and Darley to this scenario:
F does not logically imply : Given R = (J,K,L ) and the set F of FDs J -> K and L -> K , show that F does NOT logically
Variables should be private and the class functions public : All the class variables should be private and the class functions public. The class functions should be implemented in a file Inventory.cpp which should be linked with the inventory.hpp file.
Encode or decode a color combination : In the early days of computer graphics, colors where represented as two numbers. The first number was the foreground color and the second was the background color. These two values, which ranged from 0 to 15 were stored within a single byte; the fore..
Offer activities to promote diversity : "Many organizations sponsor or offer activities to promote diversity.  What types of activities or trainings do organizations offer to ensure/promote a diverse company.
This program will simulate the game of hearts : This program will simulate the game of Hearts, which is a four-player trick-taking game using any ordinary deck of playing cards. Each player is dealt thirteen cards. Whoever is dealt the Two of Clubs must lead it to the first trick. Each person p..
Harassment prevention training : What are some of the reasons an organization should have harassment prevention training?  Even though our text focuses on sexual harassment, which groups of people, in addition to women, can be targets of harassment? "

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Implement a function to recursively

Implement a function to recursively determine if a word is a palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction.

  Write the class definition for a class called complex

. Write the class definition for a class called complex.

  The user enter the total rainfall for each of 12 months

Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display:the total rainfall for the year,the average monthly rainfall,and the months w..

  Make 2-dimensional array

make 2-dimensional array a bit of life and bringing them from the abstract to the concrete realms

  Write a program to read only one integer number

Write a program to read ONLY one integer number (your input must be one 3 digit number from 100 to 999), and to think of a number as being ABC (where A, B, and C are the 3 digits of a number)

  Users to input two forces by their components

write a programm to ask users to input two forces by their components of (Fx1,Fy1) and (Fx2,Fy2) from the keyboard.call twice the function to display both magnitude and direction angle of two forces on the screen.add two forces and display both magni..

  Describe the probability of the moves

Write a program in C++ to describe the Probability of the moves

  Create a 1-dimensional (1d) array

Write a program to create a 1-dimensional (1D) array that contains 15 characters and display to the screen a count of the occurrences of each of the vowels a, e, i, o, and u in the array.

  Write a program for find greatest common divisor

Write code for a recursive implementation of Euclid's algorithm

  Program to compute the total volume

Write a program to compute the total volume for a number of cylinders. A cylinder may have different values for height and radius.

  Implement the tronomino tiling algorithm

Implement the tronomino tiling algorithm,  our program should take an arbitrary input positive integer  k  in the Linux command line and generate a 2 k  * 2 k  board.

  Class named realestate that has data members

Create a class named RealEstate that has data members to hold the price of a house, the number of bedrooms, and the number of baths. Member functions include overloaded insertion and extraction operations

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd