Class scope variables-helper methods

Assignment Help C/C++ Programming
Reference no: EM13859348

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.

Reference no: EM13859348

Questions Cloud

Determine the roots of the closed-loop transfer function : Develop an m-file to determine the roots of the closed-loop transfer function characteristic polynomial for K=1 and 5. For which values of K is the closed loop system stable
Example of a program that contains an algorithm : Provide an example of a program that contains an algorithm whose Big-Θ is exponential. Clearly explain what n represents in your program. Make some assumption about how long it would take to execute one of the operations that you are counting.
Determine the size of the project buffer : how you would use the project buffer to determine the point at which you would implement controls to correct an unacceptable project schedule variance. Determine the size of the project buffer.
Compare the calculated heat transfer values : Compare the calculated heat transfer values with those obtained from your electrical measurements. Explain the differences.
Class scope variables-helper methods : 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..
Why is accounting for a manufacturing business : In your opinion, why is accounting for a manufacturing business more complicated than accounting for a merchandising business and provide three examples each of materials, labor costs, and factory overhead.
Draw isoquants for the firms production function : Say that technology is relatively labor intensive if it uses more labor to produce the same amount of output than the other technology. Which technology A or B is labor intensive?
Calculate equilibrium products at 500k for the reaction : Calculate equilibrium products at 500K for the reaction of 1 mole CO and 1 mole H2O according to the water-gas shift reaction (CO • H2O CO2 • H2) as a function of temperature four ways
Recognize the elements and correct use of a thesis statement : Recognize the elements and correct use of a thesis statement

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Displays all the numbers

write a java program that displays all the numbers from 100 to 200, ten per line, that are divisible by 5 and 6 .

  What is printed by the following program

What is printed by the following program?

  Program that computes the total price of tickets

Write a program that computes the total price of tickets that a customer orders. The program should prompt the user for the number of the destination city and the number of tickets desired.

  Write programs to play a card game

You will write two programs to play a card game ("clubs"). A separate document describing the rules of "clubs" will be provided.The first program (clubber) will listen on its stdin for information about the game and give its moves to stdout.

  The function should accept the future value

The function should accept the future value, annual interest rate, and number of years as arguments. It should return the present value, which is the amount that you need to deposit today. Demonstrate the function in a program that lets the user expe..

  1 design and implement a c program for the given

1. design and implement a c program for the given specification.2. show a structure diagram for your program using the

  Write a function that returns a number

Write a test program that prompts the user to enter a phone number as a string. The input number may contain letters. The program translates a letter (upper- or lowercase) to a digit and leaves all other characters intact

  Write a program that will be used to gather statistical data

Write a program that will be used to gather statistical data about the number of movies

  Write a program using the rand() function

Write a program using the rand() function and a large array to find the standard deviation, variance and mean as well as the min and max values of the array.

  Create an array of boat objects

Create Classes for each of the object types that need to be stored, as indicated above.

  Find the largest element and print out the index and value

Write a function maxv() that returns the largest element of a vector argument. Find the largest element and print out the index and value.

  Write recursive and iterative versions of functions

Write recursive and iterative versions of functions that compute the sum of components of an array.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd