C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Create a class Product with <PID, cost, quantity> as member
variables. Create a parameterized constructor to assign default values for
quantity and cost and assign consecutive PID starting from 100. Create a copy
constructor, and a destructor, findMaxProduct()as a friend function that
takes an array of N Products as parameter and returns the product with
maximum quantity, getProduct() to read quantity and cost details,
printProduct() to print product details, as member functions. In main()
create an array of Product objects and call findMaxProduct()appropriately
and print the details of the product with maximum quantity.
Assume the following declarations
const int NUMROWS = 3;
const int NUMCOLS = 4;
int val[NUMROWS][NUMCOLS]={8,16,9,52,3,15,27,6,14,25,2,10};
Which statement will change the value of the element with the value 27 to 55.
1. val[0][1] = 55;
2. val[1][2] = 55;
3. val[2][1] = 55;
4. val[1][1] = 55;

Static data members of a class occupy memory once whereas non static data members occupy members as per the number of objects created. Justify the statement by writing a program.


COVID-19 has triggered panic buying from Americans with the expectation that there will be declaration of lockdown after the closure of school across the
country. Retailer are increasing the prices of their goods on the shelf based on
the time it stays on the shelf. The management of “Brutus Stores” have decided on this price policy. The price of any item which is expected to sell within a week should be increased by 20%. However, if an item stays on the shelf after a week but less than or equal to two weeks the price should be increase by 15%.
The price of any other item that stays on the shelf for more than two weeks
should be increase by 2%. As a programmer you have been consulted to
develop a program that will:

a. Request for item name, current price in $, expected duration on shelf.

b. Compute the retail price of the item.

c. Display the results.

d. Explain your results
a. C++ is known to be an object-oriented program. Objects are also known
to exist in real life. You have been invited as a computer science student
to distinguish between real life objects and object found in object oriented
program OOP.

b. Write an OOP to compare the risk factor that will lead to high payment of
life insurance premium. The variables to consider are: age, weight, and
height
1. The program should request for the variables to be inputted from the
keyboard.

2. Premium should be high if age is greater than or equal to 60 years and
weight is greater than or equal 80kg and has greater than or equal 6.8 feet. Otherwise the premium should be low.

3. Critically explain how the program could be adopted by allied companies for their operations.

Write a program which displays a given character, n number of times, using a function. When the n value is not provided, it should print the given character 80 times. When both the character and n value is not provided, it should print ‘*’ character 80 times.

 By using default arguments


Static data members of a class occupy memory once whereas non static data members occupy members as per the number of objects created. Justify the statement by writing a program.




WAP which displays a given character, n number of times, using a function. When the n value is not provided, it should print the given character 80 times. When both the character and n value is not provided, it should print *’character 80 times. [Write the above program in two ways:- -using function overloading. -using default arguments.]



Create a class containing
-Create a dynamic 2d array according to size provided by user and an integer that keeps track of its size
-insert values until user presses - 2
-Create another bigger array when previous one is full
-copy all values in the new array and release the old memory print after each insert
-ask the user to delete numbers until he presses - 2
-find the index in the original array and then remove that index from the original array
-stop when array is empty of when user presses - 2
Write a bool function which deletes an element in the linked list
-bool delete_element(int a)
Another function which checks if the list is empty
-bool isempty()
LATEST TUTORIALS
APPROVED BY CLIENTS