[Solved] COEN 243-Assignment 4 Strings/UserDefined Classes

$25

File Name: COEN_243-Assignment_4__Strings/UserDefined_Classes.zip
File Size: 471 KB

SKU: [Solved] COEN 243-Assignment 4 – Strings/User‐Defined Classes Category: Tag:
5/5 - (1 vote)

Questions

  1. (20 points) Write a userdefined function in C++ to display the multiplication of row element of two dimensional array A[5][6] containing integer. The function does not return any value. It will print the multiplication of each row. The array elements are taken from the user in the main function and then the function is called and the array is passed to the function.

Example. If A = [ 2 3 4 6 2 1 3 1 0 4 5 8 3 1 0 4 5 2 3 1 1 4 5 9

3 1 3 4 1 8 ]

It will print 288 0 0 540 288 in the output.

  1. (40 marks) We want to create a class called Edevice, which represents the electronic devices of company. A device is defined with the following attributes: category (string) (The possible values are Smartphone, Tablet, Laptop and Smartwatch), model number (int), color (string), status (boolean) (true for new and false for used), year built (int), price (double). The member functions of the class Edevic must perform the following operations:
  • Return (get) functions for all attributes
  • Modify (Set) functions for all attributes

To test your class, you need to create, a driver, which is the cpp file that contains the main function. Lets call this, testdevice.cpp. In the main function, you should prompt the user to enter information about two devices, create two objects of the class Edevice with the information entered by the user, and finally, test the member functions of the class.

Deliverables:

  • A file called h that contains the specification of the class.
  • A file called cpp that contains the implementation of the member functions of the class.
  • A file called cpp that contains the main function.

1/3

  1. (40 marks) Define a class called House, that represents the information of a house. A House is defined with these attributes: age (int), type (string) (Detached, SemiAttached, Attached), rooms (int) and cost (double). Functions of the House class must perform the following operations:
  • Return (get) functions for all attributes
  • Modify (Set) functions for all attributes
  • A function called estimatePrice() that returns cost of a house in future based on type and the number of years were looking into its price in future. So, it takes the type of the house and the year as input. An attached house, costs $100,000, appreciates 1% every year in first five years and 2% every year afterwards. A Semidetached house, costs $150,000, appreciates 2% every year in first five years and 3% every year afterwards. A Detached house, costs $200,000, appreciates2% every year in first five years and 2% every year afterwards.

Hint: Use this formula to estimate the house price in future:

Estimated price= current house price*(1+appreciation_rate)years form now

Test your class by prompting the user to enter information about two different houses. Create two objects of the class House with the information entered by the user, and finally, test the member functions of the class. Also calculate the estimated price of houses given type and age (include 1 attached and 1 detached)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COEN 243-Assignment 4 Strings/UserDefined Classes
$25