freelanceprogrammers.org Forum Index » C

Please Help Me With Tank Program


View user's profile Post To page top
neilmarvin Posted: Mon Jul 05, 2004 10:02 am


Joined: 05 Jul 2004

Posts: 2
Please Help Me With Tank Program
Hi.
could you please help me.
I am writing a tank application.
the tank is a milk cillinder. it is 2.5 meters in diameter, 4.0 in length.
the user enters a amount of mixture into the tank for a farmer.
then the user enters a amount of area to be sprayed for the paddock into the
tank.
then the mixture is calculated and the total area calculated.
then the total mixture and area is displayed on screen to the user.
then it asks if the user wants to enter more data into the tank.
if yes, then the two prompts to enter the mixture and the area to be sprayed
is displayed on screen.
then the total mixture and area sprayed is displayed on screen.
it asks the user if they want to enter more data into the tank.
if the user says no, then the program ends.
please take a look at my code.
got errors and warnings.
give me tips on how to fix the errors for this program.

I will paste the error messages and my code below.
i am a beginning programming student.
tried to fix it and tried a few things, but still does not work.
if you can help me, then e-mail me privately off list, with suggestions,
tips, code snippets.
cheers Marvin.




Error Messages Begin Here:


[C++ Warning] Tank.cpp(63): W8004 `area` is assigned a value that is never
used

[C++ Warning] Tank.cpp(63): W8004 `tank` is assigned a value that is never
used

[C++ Warning] Tank.cpp(63): W8004 `fertaliser` is assigned a value that is
never used

[C++ Warning] Tank.cpp(63): W8004 `water` is assigned a value that is never
used

[C++ Warning] Tank.cpp(63): W8004 `theta` is assigned a value that is never
used

[C++ Warning] Tank.cpp(63): W8004 `capacityInMeeters` is assigned a value
that is never used

[C++ Warning] Tank.cpp(63): W8004 `capacityInLiters` is assigned a value
that is never used

[C++ Warning] Tank.cpp(63): W8004 `length` is assigned a value that is never
used

[C++ Warning] Tank.cpp(63): W8004 `diameter` is assigned a value that is
never used

[C++ Warning] Tank.cpp(63): W8004 `dipstickLevelInMeters` is assigned a
value that is never used

[C++ Warning] Tank.cpp(63): W8004 `dipstickLevel` is assigned a value that
is never used

[C++ Warning] Tank.cpp(63): W8004 `surfaceArea` is assigned a value that is
never used

[C++ Warning] Tank.cpp(63): W8004 `segmentVolume` is assigned a value that
is never used

[C++ Warning] Tank.cpp(63): W8004 `pi` is assigned a value that is never
used

[C++ Warning] Tank.cpp(63): W8004 `radius` is assigned a value that is never
used

[C++ Error] Tank.cpp(92): E2451 Undefined symbol `tank`

[C++ Error] Tank.cpp(95): E2377 If statement missing )

[C++ Error] Tank.cpp(110): E2451 Undefined symbol `area`

[C++ Error] Tank.cpp(113): E2377 If statement missing )

[C++ Error] Tank.cpp(127): E2451 Undefined symbol `dipstickLevel`

[C++ Error] Tank.cpp(128): E2451 Undefined symbol `radius`

[C++ Error] Tank.cpp(133): E2451 Undefined symbol `length`

[C++ Error] Tank.cpp(134): E2451 Undefined symbol `segmentVolume`

[C++ Warning] Tank.cpp(136): W8004 `capacityInLiters` is assigned a value
that is never used

[C++ Warning] Tank.cpp(136): W8004 `capacityInMeters` is assigned a value
that is never used

[C++ Warning] Tank.cpp(136): W8004 `surfaceArea` is assigned a value that is
never used

[C++ Warning] Tank.cpp(136): W8004 `theta` is assigned a value that is never
used

[C++ Warning] Tank.cpp(136): W8004 `dipstickLevelInMeters` is assigned a
value that is never used

[C++ Error] Tank.cpp(141): E2451 Undefined symbol `totalCapacity`

[C++ Error] Tank.cpp(141): E2451 Undefined symbol `diameter`

[C++ Error] Tank.cpp(141): E2451 Undefined symbol `length`

[C++ Error] Tank.cpp(141): E2451 Undefined symbol `fertaliser`

[C++ Error] Tank.cpp(141): E2451 Undefined symbol `water`

[C++ Error] Tank.cpp(155): E2451 Undefined symbol `answer`







Source Code Begins Here:





/*
* Program: Tank.
* File Name: Tank.cpp.
* Author: Marvin Hunkin.
* Date Created: Monday July 5 2004.
* Description: Tank Program for a farmer to spray mixture on a paddock.
* Version: 1.0.
*/


// iostream is needed for input and output.


#include <iostream.h>
#include <math.h>
#include <iomanip.h>


using namespace std;


void DisplayTitle();
void DisplayInformation();
void PromptTank();
void PromptArea();
float GetAmountInTank();
float GetTotalCapacity();
void Result();


int main()
{
cout.setf(ios::fixed);
cout.precision(2);
cout.precision(2);


float radius=0.0;
float pi=3.14;
float segmentVolume=0.0;
float surfaceArea=0.0;
float dipstickLevel=0.0;
float dipstickLevelInMeters =0.0;
float diameter=2.5;
float length=4.0;
float capacityInLiters=2000;
float capacityInMeeters=0.0;
float theta=0.0;
float water=0.75;
float fertaliser=0.25;
float tank=0.0;
float area=0.0;
char anser;

DisplayTitle();
DisplayInformation();
PromptTank();
PromptArea();
GetAmountInTank();
GetTotalCapacity();
Result();
return 0;
} // close main function


void DisplayTitle()
{
cout << " Welcome To Marvins Tank " << endl;
cout << endl;
cout << endl;
} //close DisplayTitle function


void DisplayInformation()
{
cout << " This program asks the user to " << endl;
cout << " enter an amount of mixture into the tank. " << endl;
cout << " Another prompt appears on screen. " << endl;
cout << " Asks the user to enter " << endl;
cout << " an amount of area to be sprayed into the tank. " << endl;
cout << " Then the total amount of mixture " << endl;
cout << " and total amount of area sprayed " << endl;
cout << " is displayed on screen. " << endl;
cout << endl;
cout << endl;
} // close DisplayInformation function


void PromptTank()
{
cout << " Enter Amount Of Mixture Into The Tank: " << endl;
cin >> tank;
cout << endl;
cout << endl;
if (tank!<=0)
{
cout << " Invalid Amount! " << enhdl;
cout << " Try Again! ... " << endl;
cout << " Enter Amount Of Mixture Into The Tank: " << endl;
cin >> tank;
cout << endl;
cout << endl;
} // close if block
} // close PromptTank function


void PromptArea()
{
cout << " Enter Amount Of Area Into The Tank: " << endl;
cin >> area;
cout << endl;
cout << endl;
if (area!<=0)
{
cout << " Invalid Amount! " << enhdl;
cout << " Try Again! ... " << endl;
cout << " Enter Amount Of Area Into The Tank: " << endl;
cin >> area;
cout << endl;
cout << endl;
} // close if block
} // close PromptArea function


float GetAmountInTank()
{
float dipstickLevelInMeters =
dipstickLevel / 1000;
float depthDivideRadius = ((radius - dipstickLevelInMeters) / radius);
float theta = 2*acos(depthDivideRadius);
float pieShapedWedge = radius * radius * (theta / 2);
float triangleArea = (radius - dipstickLevelInMeters) * radius *
sin(theta / 2);
float surfaceArea = pieShapedWedge - triangleArea;
float capacityInMeters = surfaceArea * length;
float capacityInLiters = segmentVolume * 1000;
return segmentVolume;
} //close GetAmountInTank function


float GetTotalCapacity()
{
totalCapacity=diameter * length * fertaliser * 0.25 * water * 0.75;
return totalCapacity ;
} // close GetTotalCapacity function


void Result()
{
cout << " Total Mixture Used: " << GetAmountInTank() << " Litres " << endl;
cout << " Total Area Used: " << GetTotalCapacity() << " Hectres " << endl;
cout << endl;
cout << endl;


cout << " Do You Want To Enter More Data Into The Tank ( y / n ) ? " <<
endl;
cin >>answer;


while (answer!=`y`)
{
PromptTank();
PromptArea();
Result();


cout << " Do You Want To Enter More Data Into The Tank ( y / n ) ? " <<
endl;
cin >>answer;
cout << endl;
cout << endl;
}
} // close Result function
Reply with quote
Send private message
View user's profile Post To page top
neilmarvin Posted: Tue Jan 25, 2005 10:28 am


Joined: 05 Jul 2004

Posts: 2
Please Help Me With Tank Program
Hi.
was doing a assignment for my course last year.
i started creating a program for a farmer.
he has a tank which is like a cillinder and is 4 meetres long by 2.5 meetres
in diameter.
it holds up to 2000 litres.
it uses three quarters water and one quarter fertaliser.
and the paddock holds up to 10000 hectres in diameter.
the farmer wants to know how much liquid to input into a dipstick in this
tank.
then it calculates by use of several formulas how much liquid is in the
tank.
then he wants to know how much area to spray.
then it should spit out how much liquid he entered into the tank, and how
much area he has sprayed.
the program is half finished.
and had problems getting the calculations for the formulas.
i am not a maths guru, and has been a few years since i did convertion from
imperial to metric and back and forth.
so if any one can help me out and get it to work properly.
please e-mail me with the answer and how i can fix this one.
will paste the code and error messages below.
cheers Marvin.


/*
Program: Tanker.
FileName: Tanker.cpp.
Author: Marvin Hunkin.
Date Created: Monday October 18 2004.
Description: A Tanker Program.
Version: 1.0.
*/


// iostream is needed for input and output.

#include <iostream.h>

// math is needed for calculating formulas.

#include <math.h>

// ionmanip is needed for formatting numeric data to 2 digits.

#include <iomanip.h>

// name space is needed for using the libraries in c++.

using namespace std;

// a container for this function.

void Title();
void Information();
void PromptDipStickLevel();
void PromptAreaSprayed();
double CalcDipStickLevel();
double CalcAreaSprayed();
void Result();

// the main function starts here.

int main()
{
// variable to hold the answer if user wants to enter
more data into the tank.

char answer;

// c plus plus functions to format data to two decimal positions.

cout.setf(ios::fixed);
cout.precision(2);

Title();
Information();

// do while loop starts here.

do
{
PromptDipStickLevel();
PromptAreaSprayed();
CalcDipStickLevel();
CalcAreaSprayed();
Result();

// prompt to ask if user wants to enter more data into the tank.

cout << " Do You Want To Enter More Data Into The Tank ( y / n ) ? " <<
endl;

// variable is held in memory.

cin >> answer;


} // do while loop ends here.

while (answer==`y`);
return 0;
} // close main function



// the Title function starts here.

void Title()
{
cout << " Welcome To Marvins Tank " << endl;
} // close title function


// the information function starts here.

void Information()
{
cout << " This program asks the user to " << endl;
cout << " Enter an amount of liquid into the tank. " << endl;
cout << " Another prompt appears on screen. " << endl;
cout << " Asks the user to enter an amount of " << endl;
cout << " Area to be sprayed for the field. " << endl;
cout << " Then the amount of liquid and area to be sprayed " << endl;
cout << " Is displayed on screen. " << endl;
} // close information function


// the PromptDipstickLevel function starts here.

void PromptDipStickLevel()
{
// set the tank variable to zero.

float tank=0.0;

// the prompt to enter amount of liquid into the tank.

cout << "Please Enter The dipstick Level In Millimetres : " << endl;

// this variable is stored in memory.
// Holds the amount entered by the user.

cin >> tank;

// if block starts here.

if (tank<=0)
{
cout << " Error! You did not enter a valid amount into the tank. " <<
endl;
cout << " Please try again ... " << endl;
cout << "Please Enter The dipstick Level In Millimetres : " << endl;
cin >> tank;
}

// if block ends here.

// close PromptDipStickLevel function


// The PromptAreaSprayed function starts here.

void PromptAreaSprayed()
{
// set the area variable to 0.

float area=0.0;

// prompt to ask the user to enter the amount of area to be sprayed.

cout << " Please enter the amount of area to be sprayed in hectres : " <<
endl;

// this variable is stored in memory.
// Holds the amount entered by the user.

cin >> area;

// if block starts here.

if (area<=0)
{
cout << " Error! You did not enter a valid amount into the tank. " <<
endl;
cout << " Please try again ... " << endl;
cout << " Please enter the amount of area to be sprayed in hectres : " <<
endl;
cin >> area;
}

// if block ends here.


// close PromptAreaSprayed function


// CalcDipStickLevel starts here.

double CalcDipStickLevel()
{
// container to hold information for this function.

double TankLevel;

// set the millimetre variable to 1000.

double millimetre=1000;

// set the volume to 2000 litres.

double volume=2000;


// set the fertaliser to 0.25 litres.

double fertaliser=0.25;

// set the water variable to 0.75 litres.

double water=0.75;

// convert millimetres to metre.

millimetre=millimetre / 1000;
} // close CalcDipStickLevel
function



} // close CalcDipSticlLevel function
// CalcAreaSprayed function starts here.

double CalcAreaSprayed()
{
// container to hold information for this function.

double TankArea;

// set the radius variable to 1.25.

double radius=1.25;

// set the diameter variable to 2.5.

double diameter=2.5;

// set the length variable to 4.

double length=4.0;
} // close CalcAreaSprayed function


// result function starts here.

void Result()
{
// variable to hold information.

double dipstick=0.0;;

// variable to hold information.

double field=0.0;


// the amount of liquid in the tank is displayed here on screen.

cout << " The Amount Of Liquid in the tank is : " << dipstick << "
Litres " << endl;

// the amount of area to be sprayed is displayed here on screen.
cout << " The amount of area to be sprayed is : " << field << " Hectres "
<< endl;
}// close Result function


[C++ Error] Tanker.cpp(137): E2141 Declaration syntax error
[C++ Error] Tanker.cpp(240): E2139 Declaration missing ;
[C++ Error] Tanker.cpp(240): E2134 Compound statement missing }
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help