1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mekhanik [1.2K]
3 years ago
8

(1) Create three files to submit:

Computers and Technology
1 answer:
Sindrei [870]3 years ago
6 0

Answer:

We have the files and codes below with appropriate comments

Explanation:

ItemToPurchase.h:

#pragma once

#ifndef ITEMTOPURCHASE_H_INCLUDED

#define ITEMTOPURCHASE_H_INCLUDED

#include<string>

#include <iostream>

using namespace std;

class ItemToPurchase

{

public:

    //Declaration of default constructor

    ItemToPurchase();

    //Declaration of SetName function

    void SetName(string ItemName);

    //Declaration of SetPrice function

    void SetPrice(int itemPrice);

    //Declaration of SetQuantity function

    void SetQuantity(int itemQuantity);

    //Declaration of GetName function

    string GetName();

    //Declaration of GetPrice function

    int GetPrice();

    //Declaration of GetQuantity function

    int GetQuantity();

private:

    //Declaration of itemName as

    //type of string

    string itemName;

    //Declaration of itemPrice as

    //type of integer

    int itemPrice;

    //Declaration of itemQuantity as

    //type of integer

    int itemQuantity;

};

#endif

ItemToPurchase.cpp:

#include <iostream>

#include <string>

#include "ItemToPurchase.h"

using namespace std;

//Implementation of default constructor

ItemToPurchase::ItemToPurchase()

{

    itemName = "none";

    itemPrice = 0;

    itemQuantity = 0;

}

//Implementation of SetName function

void ItemToPurchase::SetName(string name)

{

    itemName = name;

}

//Implementation of SetPrice function

void ItemToPurchase::SetPrice(int itemPrice)

{

    this->itemPrice = itemPrice;

}

//Implementation of SetQuantity function

void ItemToPurchase::SetQuantity(int itemQuantity)

{

    this->itemQuantity = itemQuantity;

}

//Implementation of GetName function

string ItemToPurchase::GetName()

{

    return itemName;

}

//Implementation of GetPrice function

int ItemToPurchase::GetPrice()

{

    return itemPrice;

}

//Implementation of GetQuantity function

int ItemToPurchase::GetQuantity()

{

    return itemQuantity;

}

main.cpp:

#include<iostream>

#include<string>

#include "ItemToPurchase.h"

using namespace std;

int main()

{

    //Declaration of ItemToPurchase class objects

    ItemToPurchase item1Cart, item2Cart;

    string itemName;

    //create a variable names like itemPrice

    //itemQuantity,totalCost as type of integer

    int itemPrice;

    int itemQuantity;

    int totalCost = 0;

    //Display statement for Item1

    cout << "Item 1:" << endl;

    cout << "Enter the item name : " << endl;

    //call the getline function

    getline(cin, itemName);

    //Display statememt

    cout << "Enter the item price : " << endl;

    cin >> itemPrice;

    cout << "Enter the item quantity : " << endl;

    cin >> itemQuantity;

    item1Cart.SetName(itemName);

    item1Cart.SetPrice(itemPrice);

    item1Cart.SetQuantity(itemQuantity);

    //call cin.ignore() function

    cin.ignore();

    //Display statement for Item 2

    cout << endl;

    cout << "Item 2:" << endl;

    cout << "Enter the item name : " << endl;

    getline(cin, itemName);

    cout << "Enter the item price : " << endl;

    cin >> itemPrice;

    cout << "Enter the item quantity : " << endl;

    cin >> itemQuantity;

    item2Cart.SetName(itemName);

    item2Cart.SetPrice(itemPrice);

    item2Cart.SetQuantity(itemQuantity);

    //Display statement

    cout << "TOTAL COST : " << endl;

    cout << item1Cart.GetName() << " " << item1Cart.GetQuantity() << " @ $" << item1Cart.GetPrice() << " = " << (item1Cart.GetQuantity()*item1Cart.GetPrice()) << endl;

    cout << item2Cart.GetName() << " " << item2Cart.GetQuantity() << " @ $" << item2Cart.GetPrice() << " = " << (item2Cart.GetQuantity()*item2Cart.GetPrice()) << endl;

    totalCost = (item1Cart.GetQuantity()*item1Cart.GetPrice()) + (item2Cart.GetQuantity()*item2Cart.GetPrice());

    cout << endl;

    cout << "Total : $" << totalCost << endl;

    return 0;

}

You might be interested in
4) To run program short cut​
quester [9]

Answer:

Run Dialog

Open it by pressing WinKey+R. In the Run dialog, type the name of a program's .exe file and press Enter to launch it.

Explanation:

Please give me brainlist and follow

6 0
3 years ago
2) The CPU is made from a silicon<br>b) Chip<br>C) pendrive<br>a) Steel<br>​
Aleks [24]

Answer:

b

Explanation:

a cpu is made from silicon chip

5 0
2 years ago
ÍS THERE ANY TECH GUY OR SOMEONE WHO UNDESTAND ABOUT UNINSTALLING?
marysya [2.9K]
Well, dont know ;-: PROBLEM?
6 0
3 years ago
Game development is a time-consuming and expensive endeavor, and being a Lone Ranger is a recipe for disaster
belka [17]
False although depends on the future of the person's ideas
7 0
3 years ago
Describe the nodes in a 2-3 tree.
Vikentia [17]
In computer science, a 2–3 tree is a tree data structure, where every node with children (internal node) has either two children (2-node) and one data element or three children (3-nodes) and two data elements. According to Knuth, "a B-tree of order 3 is a 2-3 tree."
5 0
3 years ago
Other questions:
  • Which of the following is the core of an operating system that maintains the computer’s clock, starts applications, and assigns
    7·1 answer
  • According to Gitlin, during the 1950s and 60s television production costs began to exceed the licensing fees the networks paid i
    10·1 answer
  • Write the code that creates a public class named Vehicle that has one private data member. The private data member is an integer
    13·1 answer
  • Why are duplicate tuples not allowed in a relation?
    6·1 answer
  • Kyla, a business analyst uses test scripts while testing an application before it is released to the client. Why do business ana
    5·1 answer
  • Var words = ["apple", "bug","car", "dream", "ear", "food"]
    6·2 answers
  • In Super Mario Bros., you become Mario and your friend is Mario’s younger brother Luigi. Your job is to race through Mushroom Ki
    10·1 answer
  • Jason is the motion picture projectionist at the local IMAX theater. This means that he runs the huge movie projector so that cu
    12·1 answer
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. Please select the
    12·1 answer
  • Identify an internal user who uses product lifecycle management (plm) software and its data.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!