Design a c windows application to compute the cost of


Objectives:

  • Class scope variables
  • Helper Methods

Program:  Design a C# Windows Application to compute the cost of manufacturing different objects. The object can be a cylinder, a cone or a prism with the equilateral triangular base. The user should enter the radius of the base (or the side of the base for prism), the height, and select the object via radio buttons. Then the user can click on the Compute button to compute the cost of manufacturing one object. The GUI of this lab is given in figure-1.

450_Windows Application.jpg

Named Constants: Declare two named constants with class scope:  PI = 3.14159, and unit price of the material used in manufacturing the objects = $2.50 per cubic inches.

Class Scope Variables:  Declare 3 class scope variables to count the number of cylinders, cones, and prisms processed (A Class scope identifier must be declared outside all methods, in Form1 class code).

Required Helper Methods:

NOTE: Precede the code for each helper method with a segment of comments, identifying the method's name, input parameters, output data type and task.

1) ValidateInput( )

a) Input: none

b) Output data type: bool

c) Task: Validate user's input based on following rules:

i. Input data entered for radius (or side) must be a real number, greater than 0.

ii. Height must be a real number; greater than 0.

iii. One of the shapes (radio buttons) must be selected.

In case of invalid input, inform the user, set the focus to the Textbox, and return false.

2) ComputeVolumeCylinder

a) Input: radius and height

b) Output data type: double

c) Task: Compute the volume of the cylinder with given radius and height. The formula is: Volume = πR2H. Return the volume as output.

2) ComputeVolumCone

a) Input: radius and height

b) Output data type: double

c) Task: Compute the volume of the cone with given radius and height. The formula is: Volume  = (1/3) πR2H. Return the volume as output.

d)      

3) ComputeVolumPrism

a) Input: side of the equilateral triangle at the base (3 sides are equal) and the height of the prism.

b) Output data type: double

c) Task: Compute the volume of the prism:

i. Invoke the helper method ComputeTriangleArea() to compute the area of the triangular base.

ii. Compute the volume  =   area of the base * height.

iii. Return the volume as output.

4) ComputeTriangleArea()

a) Input: 3 sides of the triangle

b) Output data type: double

c) Task: Compute the area of the triangle based on its three sides using Heron's formula. Return the area as output. The formula is:

721_Compute the area of the triangle.jpg

Where: a, b, c are the sides of the triangle.

Compute Button:

- Declare variables.

- Call ValidateInput( ) to validate input data. If data is not valid, do nothing.

- Store valid data in variables.

- If the selected object is a cylinder,

o Call ComputeVolumeCylinder ( )

o Update the counter ( increment # of cylinders processed by 1).

- Otherwise, if the object is a cone

o Call ComputeVolumeCone ( )

o Update the counter.

- Otherwise         // object must be a prism

o Call ComputeVolumePrism ( )

o Update the counter.

- Compute the cost = volume * unit price of the material (see named constant).

- Display the object's name, its volume, and the cost.

Stats Button:

Display number of cylinders, cones, and prisms processed. These are your class scope variables that should be updated in the click event of the Compute button.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Design a c windows application to compute the cost of
Reference No:- TGS01142111

Now Priced at $80 (50% Discount)

Recommended (99%)

Rated (4.3/5)