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
viktelen [127]
4 years ago
8

Consider the definition of the following class: (1, 2, 3, 5, 7) class productType //Line 1 { //Line 2 public: //Line 3 productTy

pe(); //Line 4 productType(int, double, double); //Line 5 productType(string, int, double, double); //Line 6 productType(string, string, string, int, double, double); //Line 7 void set(string, string, string, int, double, double); //Line 8 void print() const; //Line 9 void setQuantitiesInStock(int x); //Line 10 void updateQuantitiesInStock(int x); //Line 11 int getQuantitiesInStock() const; //Line 12 void setPrice(double x); //Line 13 double getPrice() const; //Line 14 void setDiscount(double d); //Line 15 double getDiscount() const; //Line 16 private: //Line 17 string productName; //Line 18 string id; //Line 19 string manufacturer; //Line 20 int quantitiesInStock; //Line 21 double price; //Line 22 double discount; //Line 23 }; //Line 24 a. Give the line number containing the constructor that is executed in each of the following declarations. i. productType product1; 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);
Computers and Technology
1 answer:
Shkiper50 [21]4 years ago
6 0

Answer:

The C++ codes are given below with appropriate comments

Explanation:

// productType.h

#ifndef PRODUCTTYPE_H

#define PRODUCTTYPE_H

class productType

{

public:

productType();

productType(int , double ,double);

productType(string,int , double ,double);

productType(string,string,string,int , double ,double);

void set(string,string,string,int , double ,double);

void print() const;

void setQuantitiesInStock(int x);

int getQuantitiesInStock() const;

void updateQuantitiesInStock(int x);

 

void setPrice(double x);

double getPrice() const;

void setDiscount(double d);

double getDiscount() const;

 

 

 

private:

// Declaring variables

string productName;

string id;

string manufacturer;

int quantitiesInStock;

double price;

double discount;

};

#endif

=============================

// productType.cpp

#include <iostream>

using namespace std;

#include "productType.h"

productType::productType()

{

this->productName="";

this->id="";

this->manufacturer="";

this->quantitiesInStock=0;

this->price=0.0;

this->discount=0.0;

}

productType::productType(int quantitiesInStock, double price,double discount)

{

this->productName="";

this->id="";

this->manufacturer="";

this->quantitiesInStock=quantitiesInStock;

this->price=price;

this->discount=discount;

}

productType::productType(string productName,int quantitiesInStock, double price,double discount)

{

this->productName=productName;

this->id="";

this->manufacturer="";

this->quantitiesInStock=quantitiesInStock;

this->price=price;

this->discount=discount;

}

productType::productType(string productName,string id,string manufacturer,int quantitiesInStock, double price,double discount)

{

this->productName=productName;

this->id=id;

this->manufacturer=manufacturer;

this->quantitiesInStock=quantitiesInStock;

this->price=price;

this->discount=discount;

}

void productType::set(string productName,string id,string manufacturer,int quantitiesInStock, double price,double discount)

{

this->productName=productName;

this->id=id;

this->manufacturer=manufacturer;

this->quantitiesInStock=quantitiesInStock;

this->price=price;

this->discount=discount;

}

void productType::print() const

{

cout<<"Product Name :"<<productName<<endl;

cout<<"Id :"<<id<<endl;

cout<<"Manufacturer :"<<manufacturer<<endl;

cout<<"Quantities In Stock :"<<quantitiesInStock<<endl;

cout<<"Price :$"<<price<<endl;

cout<<"Discount :%"<<discount<<endl;

}

void productType::setQuantitiesInStock(int x)

{

this->quantitiesInStock=x;

}

int productType::getQuantitiesInStock() const

{

return quantitiesInStock;

}

 

void productType::setPrice(double x)

{

this->price=x;

}

double productType::getPrice() const

{

return price;

}

void productType::setDiscount(double d)

{

this->discount=d;

}

double productType::getDiscount() const

{

return discount;

}

void productType::updateQuantitiesInStock(int x)

{

this->quantitiesInStock=x;

}

=============================

// main.cpp

#include <iostream>

using namespace std;

#include "productType.h"

int main()

{

productType pt("Mobile","1234","Lenovo",34,1500,10);

pt.print();

 

pt.updateQuantitiesInStock(50);

cout<<"\nAfter Modifying the quantity ::"<<endl;

pt.print();

 

return 0;

}

You might be interested in
Technology can help governments handle economic emergencies, such as the reliance on automation. Crop and resource shortages. Th
uranmaximum [27]

Answer

Technology can help government handle economic emergencies such as crop and resource shortages.

Explanation

The government can address the concerns of food shortages and water scarcity through embracing new technology interventions to increase farm yields and mitigate the impacts of water shortages. Through crop protection methods, weeds and pest can be controlled. Drip irrigation technology applies water directly to the roots of crops to facilitate high crop production. Other technologies to apply can include organic agriculture and integrated soil fertility management.



3 0
3 years ago
Read 2 more answers
In 2-4 sentences, explain the difference between the “save” and the “save as” commands.
yuradex [85]
The "save" command means to save it again, or to save the changes you made to an already saved document. The "save as" command means to save it for the first time and you enter in what you want to name to document youre saving
4 0
4 years ago
Read 2 more answers
Create a function called biggestNum that returns the largest number in an array of integers. The function is passed only one par
goldenfox [79]

This is for Python

def biggestNum():

   array = []

   for i in range(8):

       number = int(input('Enter number: '))

       array.append(number)

   

   return max(array)

print(biggestNum())

5 0
3 years ago
Predict the future that social media will have on society or the environment
hichkok12 [17]

Answer:

The future that this world holds for Social media may as well be known as the end of self opinions. This is because now  a days many people seek the opinions of others and no longer take there opinions into count. Social media can also damage the environment. This is because since people are on there phone longer bc of social media they also need to charge there phone more, which needs electricity, which comes from the burning of fossil fuels .

5 0
3 years ago
Which of the following items is not found on a web page?
navik [9.2K]
The answer is B. book mark definitely
7 0
3 years ago
Other questions:
  • g The reciprocal Fibonacci constant ψ is defined by the infinite sum: ψ=∑n=1 [infinity] 1 Fn Where Fn are the Fibonacci numbers
    7·1 answer
  • Which type of computer do dedicated gamers and video editors prefer?​
    11·1 answer
  • Given a variable n refers to a positive int value, use two additional variables, k and total to write a for loop to compute the
    13·1 answer
  • A technician is troubleshooting an employee laptop that has a wired network connectivity issue. The laptop can connect to the in
    9·2 answers
  • Describe data center technology and its relevance to modern-day cloud computing
    14·1 answer
  • You recently started working part-time in a retail store, and are learning about the reading devices your store uses. Your store
    6·1 answer
  • Why is it important to have at least one backup stored off-site?
    8·1 answer
  • When working in Photoshop with the move tool, you can select multiple layers and use this option to arrange them into a straight
    7·2 answers
  • PLEASEE HELPP.... QUESTION... how does coding impact your life​
    14·2 answers
  • Purchase computing resources as an outsourced service from suppliers who own and maintain all the necessary equipment and softwa
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!