Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm not sure how to finish the code to match the sample output in the picture. Do I need to do the same thing I

I'm not sure how to finish the code to match the sample output in the picture. Do I need to do the same thing I did in the 'hammer' output?

(please try to match how I coded my work so that I could easily understand. Thank you)

image text in transcribed

#include

using namespace std;

class Invoice //create class called Invoice { private: //Only for Invoice class string inClassNumber; string inClassDescription; int inClassQuantity; int inClassPrice;

public: //Included in main Invoice(string number, string description, int quantity, int price) { inClassNumber = number; inClassDescription = description; inClassQuantity = quantity; inClassPrice = price; }

//set function void set_inClassNumber(string num) /umber { inClassNumber = num; } void set_inClassDescription(string desc)//description { inClassDescription = desc; } void set_inClassQuantity(int qty) //quantity { if(qty

//get function string get_inClassNumber() /umber { return inClassNumber; } string get_inClassDescription() //description { return inClassDescription; } int get_inClassQuantity() //quantity { return inClassQuantity; } int get_inClassPrice() //price { return inClassPrice; }

//find invoice amount int get_invoiceAmount() { int amount; amount = inClassQuantity*inClassPrice;

return amount; }

};

int main() //main { Invoice invoice("12345", "Hammer", 100, 5); //invoice hammer example cout

return 0; }

C++ Creating Classes (Invoice Class) Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four data members-a part number (type string), a part description (type string), a quantity of the item being purchased (type int) and a price per item (type int). Your class should have a constructor that initializes the four data members. Provide a set and a get function for each data member. In addition, provide a member function named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as an int value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to O. Write a test program that demonstrates class Invoice's capabilities. The following is a sample of what your output may look like: Heidis-MacBook-Pro-3:classChallenge heidis ./a.out Part number: 12345 Part description: Hammer Quantity: 100 Price per item: $ 5 Invoice amount: $500 quantity cannot be negative. quantity set to 0. Invoice data members modified Part number: 123456 Part description: Saw Quantity: 0 Price per item: $10 Invoice amount: $0 Heidis - MacBook-Pro-3:class Challenge heidis

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

How should Grandview go about implementing a global rewards system?

Answered: 1 week ago

Question

What are the determinants of cash cycle ? Explain

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago