in my cylinderType header file? If so, I would assume before the class definition? The book wasn't very elaborate on this. any help is appreciated. Thank you
Ok, I fixed that problem ( I edited my code I posted on here as well). But now when I compile I am getting this error, when it is on the generating code part.
Chapter 11 Number 4.obj : error LNK2019: unresolved external symbol "public: __thiscall cylinderType::cylinderType(double,double)" (??0cylinderType@@QAE@NN@Z) referenced in function _main
I know the topic is wrong. I just don't want to repost for each question I have, unless I need to.
When I run this code, my result of my conversion.convert is HUGE! I had this problem with my area and volume and figured it out with help. This time I am not sure. My only thinking is to re-write the conversion files and have them get the area, then use the convert formula. Any ideas?
Show that constructor that you coded.
Your problem is the same that that time, you don't initialize your variables.
`column' and `liters' are not related in any way, but you seem to assume that their state is the same.
So when you ask `liters' to `convert()' it uses its own `rad' and `heigh', which contain garbage.
I have started re-working my code right now. The more I write on it, the more I realize some mistakes I've made and ways to smooth it out. For instance, I am incorporating my area, volume and measurement conversion all into class cylinderType. Is that what you mean in that I am abusing inheritance?
This is the problem I was given:
Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice and water, in cylindrical containers. The shipping charges depend on the amount of the liquid in the container. (For simplicity, you may assume that the container is filled to the top.) They also provide the option to paint the outside of the container for a reasonable amount. Write a program that does the following:
a. Prompts the user to input the dimensions (in feet) of the container (radius of the base and the height).
b. Prompts the user to input the shipping cost per liter.
c. Prompts the user to input the paint cost per square foot. (Assume that the entire container including the top and bottom needs to be painted.)
d. Separately outputs the shipping cost and the cost of painting.
You program must use the class cylinderType to store the radius of the base and the height of the container.
I have since dropped my derived class. The only way I can think of this problem is to do one class for my area, volume and conversion. Would it make sense to use a derived class if the user wants to paint the cylinder?
> I am incorporating my area, volume and measurement conversion all into class cylinderType.
> Is that what you mean in that I am abusing inheritance?
No. A `conversion' should only convert a measure from one unit to the other.
It is not a cylinder.
A cylinder is a solid, ¿why does it care about units? It is not its responsibility to make conversions.
You also could say
1 2
cylinder::cylinder( unit radius, unit height )
unit cylinder::area() const
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include "paint.h"
#include "cylinderType.h"
usingnamespace std;
int main()
{
double radius;
double height;
double shippingCost;
double amountDue;
int decision;
double paintCost;
cylinderType cylinder;
paint painted;
cout << fixed << showpoint << setprecision(2);
cout << "Welcome to Amanda and Tyler's Cylinder Painting and Shipping.\nPlease enter the radius and the height of the cylinder, in feet: " << endl;
cin >> radius >> height;
cout << endl;
cylinder.setDimension(radius, height);
cout << "The volume of your cylinder is: " << cylinder.volume() << endl;
cout << "The volume of your cylinder in liters is: " << cylinder.literVolume() << " liters." << endl;
cout << "How much is the shipping cost, per liter? ";
cin >> shippingCost;
cout << endl;
amountDue = shippingCost * cylinder.literVolume();
cout << "Your amount due today is: $" << amountDue
<< " Would you like it painted before shipping? 1 for Yes or 2 for No: ";
cin >> decision;
cout << endl;
if (decision == 2)
cout << "Your amount due is still: $" << amountDue
<< " Thank you for shopping with us today!" << endl;
elseif (decision == 1)
cout << "The area of your cylinder is: " << painted.area() << endl;
cout << "How much is the paint cost per square foot?";
cin >> paintCost;
cout << endl;
amountDue = paintCost * painted.area();
cout << "Your new amount due is: $" << amountDue
<< " Thank you for shopping with us today!" << endl;
return 0;
}
Yes, I know I could make the paint decision a Boolean value but I am still unsure on that right now. I am mainly wanting to get this program done since I've been workin on it for too long and the if...else statement was an easier way to go.
Didn't try it before I posted it. Yes, i know now the if...else won't work. This problem is going to drive me nuts. I am late on it, and every route I try I bang my head.