(Write C++ Code) (computer science)     1. Monitor class header file: Monitor.h Instructions: 1.  Code the class specification file and name it as Monitor.h.  You can code the constructor initialization steps in-line. The rest of the member functions should just be prototypes. The class specification should define the prototypes of each functions. Class name:  Monitor Private Member Attributes: string brand string model int    width (px)  int    height(px) int    ppi double refreshRate (hz) char   speakers (Y/N) int    ports (no. of ports) string portType (list of port types separated by commas) Public Member Inline Functions Default Constructor with no parameters will initialize all numeric variables to 0. Constructor that accepts 3 int parameters for width, height, ppi.  This constructor defaults the brand to "Generic", model to "Basic", the refreshRate to 60, speakers to 'N', ports to 1, and portType to "HDMI". Destructor  (empty destructor) Public Member Functions as Prototypes: Prototype for Setters (Mutators) for each member attribute that takes parameter for the attribute and returns no value. Prototype for Getters (Accessors) for each member attribute returns the data type as specified in the attribute list. Prototype for getScreenSize() function that calculates and returns the diagonal size of the monitor in inches.  Be sure the data types will not demote numbers in the calculations. Use the formula:        Diagonal = √ (w/ppi)^2 + (h/ppi)^2  Use: sqrt() and pow(x,y) functions         4. Prototype for listMonitor() that takes no parameter and no return value but generates cout of the the Monitor as: Brand: Acer,Model: H243H,Screen size (pixels) 1920x1080 @ 70ppi, (diagonal) "result of getScreenSize"        Monitor class - Monitor.cpp Instructions: 2.  Code the class cpp file and name it as Monitor.cpp.  This should contain the setters and getter functions that are not inline, including the getScreenSize function and listMonitor function.  Return type should be int. You do not need to round the results of the calculation. Class name:  Monitor Private Member Attributes: string brand string model int    width (px)  int    height(px) int    ppi double refreshRate (hz) char   speakers (Y/N) int    ports (no. of ports) string portType (list of port types separated by commas) Public Members Functions that are not inline: Setters (Mutators) for each member attribute Getters (Accessors) for each member attribute returns the data type as specified in the attribute list. getScreenSize() function that calculates the diagonal size of the monitor in inches.  Be sure the data types will not demote numbers in the calculations. Use the formula below. listMonitor function that list Monitor specifications. Brand: Acer,Model: H243H,Screen size (pixels) 1920x1080 @ 70ppi, (diagonal) "result of getScreenSize"  Diagonal = √ (w/ppi)^2 + (h/ppi)^2   Use: sqrt() and pow(x,y) functions         Instructions: 1) Code main() function and name it getMonitors.cpp. 2) Instantiate an Acer object of the Monitor class  and set width and height as 1920 x 1080, Brand as Acer, Model as H243H, and ppi as 70, 1 HDMI port, 60Hz refresh rate.  Call the functions to calculate the  Screen Size and write the output listing. Output should be: Brand: Acer,Model: H243H,Screen size (pixels) 1920x1080 @ 70ppi, (diagonal) "result of getScreenSize" 3) Instantiate a Sony object of the Monitor class and set width and height as 1440 x 980, Brand as Sony, Model as VX200, and ppi as 72, 1 HDMI port, 60Hz refresh rate.  Call the functions to calculate the Screen Size and write the output listing  the Sony monitor. Brand: Sony,Model: VX200,Screen size (pixels) 1440x980@ 72ppi, (diagonal) "result of getScreenSize" 4) Upload the getMonitors.cpp.           Upload image file showing test run and results of getMonitors C++ program.  Image can be generated from either console command line or IDE run dialogue.   Draw a UML diagram for the Monitor class.   Upload the image of the Monitor class UML diagram.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 18SA
icon
Related questions
Question

(Write C++ Code)

(computer science)

 

 

1. Monitor class header file: Monitor.h

Instructions:

1.  Code the class specification file and name it as Monitor.h.  You can code the constructor initialization steps in-line. The rest of the member functions should just be prototypes.

The class specification should define the prototypes of each functions.


Class name:  Monitor
Private Member Attributes:

  1. string brand
  2. string model
  3. int    width (px) 
  4. int    height(px)
  5. int    ppi
  6. double refreshRate (hz)
  7. char   speakers (Y/N)
  8. int    ports (no. of ports)
  9. string portType (list of port types separated by commas)

Public Member Inline Functions

  1. Default Constructor with no parameters will initialize all numeric variables to 0.
  2. Constructor that accepts 3 int parameters for width, height, ppi.  This constructor defaults the brand to "Generic", model to "Basic", the refreshRate to 60, speakers to 'N', ports to 1, and portType to "HDMI".
  3. Destructor  (empty destructor)

Public Member Functions as Prototypes:

  1. Prototype for Setters (Mutators) for each member attribute that takes parameter for the attribute and returns no value.
  2. Prototype for Getters (Accessors) for each member attribute returns the data type as specified in the attribute list.
  3. Prototype for getScreenSize() function that calculates and returns the diagonal size of the monitor in inches.  Be sure the data types will not demote numbers in the calculations. Use the formula:

       Diagonal = √ (w/ppi)^2 + (h/ppi)^2 
Use: sqrt() and pow(x,y) functions

        4. Prototype for listMonitor() that takes no parameter and no return value but generates cout of the the Monitor as:

Brand: Acer,Model: H243H,Screen size (pixels) 1920x1080 @ 70ppi, (diagonal) "result of getScreenSize"

 
 

  

  1. Monitor class - Monitor.cpp

    Instructions:
    2.  Code the class cpp file and name it as Monitor.cpp.  This should contain the setters and getter functions that are not inline, including the getScreenSize function and listMonitor function.  Return type should be int. You do not need to round the results of the calculation.
    Class name:  Monitor
    Private Member Attributes:

    1. string brand
    2. string model
    3. int    width (px) 
    4. int    height(px)
    5. int    ppi
    6. double refreshRate (hz)
    7. char   speakers (Y/N)
    8. int    ports (no. of ports)
    9. string portType (list of port types separated by commas)

    Public Members Functions that are not inline:

    1. Setters (Mutators) for each member attribute
    2. Getters (Accessors) for each member attribute returns the data type as specified in the attribute list.
    3. getScreenSize() function that calculates the diagonal size of the monitor in inches.  Be sure the data types will not demote numbers in the calculations. Use the formula below.
    4. listMonitor function that list Monitor specifications.

    Brand: Acer,Model: H243H,Screen size (pixels) 1920x1080 @ 70ppi, (diagonal) "result of getScreenSize"

     Diagonal = √ (w/ppi)^2 + (h/ppi)^2  


    Use: sqrt() and pow(x,y) functions

     

     
     
     
  1. Instructions:

    1) Code main() function and name it getMonitors.cpp.

    2) Instantiate an Acer object of the Monitor class  and set width and height as 1920 x 1080, Brand as Acer, Model as H243H, and ppi as 70, 1 HDMI port, 60Hz refresh rate.  Call the functions to calculate the  Screen Size and write the output listing. Output should be:

    Brand: Acer,Model: H243H,Screen size (pixels) 1920x1080 @ 70ppi, (diagonal) "result of getScreenSize"

    3) Instantiate a Sony object of the Monitor class and set width and height as 1440 x 980, Brand as Sony, Model as VX200, and ppi as 72, 1 HDMI port, 60Hz refresh rate.  Call the functions to calculate the Screen Size and write the output listing  the Sony monitor.

    Brand: Sony,Model: VX200,Screen size (pixels) 1440x980@ 72ppi, (diagonal) "result of getScreenSize"

    4) Upload the getMonitors.cpp.

     

     
     
     

 

Upload image file showing test run and results of getMonitors C++ program.  Image can be generated from either console command line or IDE run dialogue.

 

Draw a UML diagram for the Monitor class.   Upload the image of the Monitor class UML diagram. 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 1 images

Blurred answer
Knowledge Booster
Types of Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr