Chat with us, powered by LiveChat c++ hw - Wridemy

c++ hw

When writing C++ programs include comments in your code, make the program readable by indenting, use meaningful variable and function names, give end users instructions on what the program does and produce meaningful output.

Program: 20 points – shapes1.cpp

 

Create the following class hierarchy

  1. Shape has nothing in it for now, we will add stuff to shape next assignment.  Just the begin/end and semicolon {};

  2. Circle class, you can grab from CS 112 Wed. Sep. 30th slide #16 or #17.  Make this circle class a derived class of Shape.  Rename calc_circum to calc_perimeter, this will be done so we have matching method names in all our objects (since circumference is really a circle’s perimeter it is okay to rename this).  You can remove the constructors and the destructor methods if you want as we will just be using the default methods for these.

  3. Sphere class, you will make as a derived class of Circle.  You will add member function calc_volume and override parent's member function calc_area.  NO new data, you will use the radius from circle that you inherit.  
    calc_volume will return the value from the sphere volume formula 4.0/3.0*3.14*radius*radius*radius;
    calc_area will return the value from the sphere area formula 4.0*3.14*radius*radius;

  4. Rectangle class, you will make as a derived class of Shape.  The object will have length and width.  You will have to create the following methods – store_sides, return_sides (or two return sides), calc_area (length*width), calc_perimeter (2*length + 2*width).

  5. Square class, you will make as a derived class of Rectangle.  You will need to create two methods store_side and return_side (one side only).  NO new data, you will use the length and width inherited from Rectangle.  You will also use the calc_area and calc_perimeter methods inherited from Rectangle for output.   

 

When the program runs, you will prompt for the type of shape to enter – then using a switch/case statement you will create the requested object, prompt for the required values for the type of object requested, then print out the perimeter (volume for sphere) and the area.  You program should prompt for unlimited number of objects, meaning your switch/case will need to be in a while loop – allowing the user to quit when entering a ‘Q’.

 

Example program run:

 


This program will ask for a shape and calculate the area and perimeter (or volume).

 

What shape do you want to enter (c=Circle, p=Sphere, r=Rectangle, s=Square, q=Quit) ?c

Enter Radius of your Circle :5

The Circle

       with radius of 5

       has a perimeter of 31.4

       and has an area of 78.5

 

What shape do you want to enter (c=Circle, p=Sphere, r=Rectangle, s=Square, q=Quit) ?p

Enter Radius of your Sphere :6

The Sphere

       with radius of 6

       has a volume of 904.32

       and has an area of 452.16

 

What shape do you want to enter (c=Circle, p=Sphere, r=Rectangle, s=Square, q=Quit) ?r

Enter Length and Width of your Rectangle :4 5

The Rectangle

       with length of 4 width of 5

       has a perimeter of 18

       and has an area of 20

 

What shape do you want to enter (c=Circle, p=Sphere, r=Rectangle, s=Square, q=Quit) ?s

Enter side of your Square :6

The Square

       with sides of 6

       has a perimeter of 24

       and has an area of 36

 

What shape do you want to enter (c=Circle, p=Sphere, r=Rectangle, s=Square, q=Quit) ?d

Invalid option

 

What shape do you want to enter (c=Circle, p=Sphere, r=Rectangle, s=Square, q=Quit) ?q

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Wridemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order