renork 0 Newbie Poster

Ok so Im working on my last lab for class and I decided to try to do it in object oriented since thats what my next class is pretty much all about. Never hurts to get a head start. However Im having difficulty figuring it out from the book. Can anyone help me get through this project in a way I might understand better?

This is the lab instructions.

A Tank initially contains 300 gallons of water in which 10lbs of salt have been dissolved. Water containing .03 lbs of salt per gallon flows into the tanke at the rate of 5 gallons per min and the well stired solution purs out at a rate of 4 gallons per min. Also every 5 min a two gallon bucket of solution is removed. Determine the contents of the tank(both salt and water) after 30 min. Use time intervals of 1.5 min, .10 min, and .01 min. Output the amounts at each interval.


This is what I have so far.

#include <iostream>
using namespace std;

class tank
{
public:
	tank();
	void water(int, int);
	void salt(int, int, int);
	void bucket(int, int, int);

private:
	int w;
	int s;
	int ti;
}
tank::tank()
{
	w=300;
	s=10;
}
void tank::water(int w, int ti)
{
	if(ti<30)
	{
	w = ((w+5)*ti)-(4*ti);
	cout << w;
	cout << ti;
	ti=ti+ti;
	}
}
void tank::salt(int s,int w, int ti)
{
	if(ti<30)
	{
	s = ((s+.3)*5*ti)-((s/w)*4*ti);
	cout << s;
	cout << ti;
	ti=ti+ti;
	}
}
void bucket(int s, int w, int ti)
{
	for(int five=0; five<30; five++)
	{
	s=(s-(s/w*2));
	w=w-2;
	}
	}

int main()
{
	tank t;
	t.water;
	t.salt;
	t.bucket;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.