Starting from:

$20

Assignment #1: function, class, and basic programming skill 

Develop a program using Visual c++ 2017 to perform the following:

1) Create a function sum (). It has one integer parameter x. Precondition: x is a non-negative integer. Post condition: the function will return 0+1 +2+...+x. If x is negative, the function returns -1 to show an invalid parameter was received.

2) Create a header file that has a class ball. The ball class has one private variable: float radius. It has two constructors. One sets the default radius to O if the programmer doesn't specify a specific value. Another one use the programmer assigned value to set the value of radius. The class has two functions for the programmer to set the value for radius or inquire the value of radius. Two other functions are: volume and surface area. Google the internet to find the formulas if you don't remember them.

3) In your application file and in the main function, create two balls x and y. Don't set the radius value for x, but set the radius of y as 10 in the same statement when you create the ball y. Ask the user to provide the radius for x. Display the following message:

The volume of x is ???% of the volume of y. The surface area of x is??? % of the surface area of y. The ??? should be returned by the functions you defined in the class.

4) Submit your answer to blackboard. See "How to submit your assignment" in the Course Information area.

More products