2023 When writing C programs include comments in your code make the program readable | Assignment Collections

Computer Science 2023 c++ hw

2023 When writing C programs include comments in your code make the program readable | Assignment Collections

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

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational