[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1137
  • Last Modified:

Class Sample?

Not quite sure how to do this...

Implement a class SodaCan with functions get_surface_area() and get_volume(). In the constructor, supply the height and radius of the can. Download lab5a.cpp. This skeleton program only contains a driver of class SodaCan, but the class interface and implementation are missing. Your job is to complete this program.

Formulas ( pi=3.1415926, R is radius, H is height):
can surface area = 2piRH +2piR2
can volume = piR2H

Your complete program should display the following results (or approximate values):
785.398
471.239

#include <iostream>

using namespace std;

/**
   A cylindrical can.
*/

//define interface here:
class SodaCan
{

};


//implemente the class Can here:



// a driver:
int main()
{
   SodaCan can(10, 5); //height is 10, and radius is 5
   cout << can.get_volume() << "\n";
   cout << can.get_surface_area() << "\n";
   return 0;
}
0
Geezy1984
Asked:
Geezy1984
1 Solution
 
brettmjohnsonCommented:
This appears to be an academic assignment.   The instructions are clear.  The skeletal program provides most of the infrastructure, leaving your task to implement the specified class methods.  The experts here cannot do your homework for you - neither of us would learn anything.  If you are having some difficulty doing the assignment, you may ask for some assistance.  But you cannot simply post the assignment here and expect someone to do all the work for you.
0
 
rajeev_devinCommented:
You have the basic idea in your disposal. Just implement the function.
And if you face any difficuly after implementation then post you questions.
0
 
krushoCommented:
//define interface here:
class SodaCan
{
  public:
   float get_surface_area();
   float get_volume();

  private:
   int height;
   int radius;
};

just implement those 2 functions
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now