Hi.
can any one help?
my code is having problems.
my second message in my code does not appear on screen.
also when i hit n to exit the loop.
it does not exit the program automatically.
please help me if you can.
i will post the code below.
please send today if possible.
i need to hand it up to my teacher today.
cheers Marvin.
 
 
 /*
* Program: C++ Session 21 Exercise
* File Name: Tanker.cpp
*Description: Session 21 Exercise to design a program for a farmer to water a area of his paddock
* Creator: Marvin Hunkin
*Date Created: Friday March 19 2004 3:35 pm
 * Version: 1.00
 */
 
 
 
//iostream is needed for input and output
 

#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <iomanip.h>
 
using namespace std;
 
 
 
class Tanker
{
        public:
 float radius;
        float length;
        float fertaliser;
 float water;
 float size;
 float hectre;
float diameter;
float EnterTank;
float EnterArea;
float theta;
float pi;
float tankAmount;
float totalLitersToSpray;
float litersToMix;
 
void Title();
 float TotalVolume();
 float VolumeOccupiedSpace(float depth);
 int Convert();
 void PromptDipStickLevel();
 void PromptArea();
  float CalculateArea(float fertaliser, float water);
 void Result();
 };  //close Tanker class
 

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

                    Tanker myTanker;
 

 myTanker.fertaliser=0.25;
 myTanker.water=0.75;
 myTanker.hectre=2000;
        myTanker.diameter=2.5;
        myTanker.radius=1.25;
        myTanker.length=4.0;
        myTanker.EnterTank=0.0;
                    myTanker.EnterArea=0.0;
                    myTanker.pi=3.14;
                    myTanker.tankAmount=0.0;
                    myTanker.totalLitersToSpray=0.0;
                    myTanker.litersToMix=0.0;
                    myTanker.Title();
                    myTanker.PromptDipStickLevel();
                    myTanker.PromptArea();
                                               myTanker.Result();
 

char answer;
 

                    cout << "Do you want to enter more data into the tanker(y/n)?" << endl;
                    cin >> answer;
                                  while (answer=='y')                                                       while (answer='n')
                                                                {
                                                                myTanker.PromptDipStickLevel();
                                                                myTanker.PromptArea();
                                                                myTanker.Result();
                    cout << "Do you want to enter more data into the tanker(y / n)? " << endl;
                                                                cin >> answer;
                    } //close while loop
                                                          getch();
                                        return 0;
} //close main function
 

 void Tanker::Title()
{
cout <<"\nWelcome To Marvin's Tanker " << endl;;
cout << "\nThis program asks the user to enter a number for the amount of liquid ";
  cout << "\nTo be entered into the tanker. ";
cout << "\nAnother prompt appears on screen.";
cout << "\nAsks the user to enter the amount of area for the paddock.";
            cout << "\nThen the total fertaliser, total water used for the paddock appears on screen.";
cout << endl;
cout << endl;
} //close title function
 

 float Tanker::TotalVolume()
{
 
float answer;
  answer = pi * radius * radius * length;
         return answer;
} //close total Volume function
 
 float Tanker::VolumeOccupiedSpace(float depth)
{
    float depthDivideRadius = ((radius - depth) / radius);
                  float theta = 2*acos(depthDivideRadius);
                      float pieShapedWedge = radius * radius * (theta / 2);
          float triangleArea = (radius - depth) * radius * sin(theta / 2);
          float surfaceArea = pieShapedWedge - triangleArea;
          float segmentVolume = surfaceArea * length;
          segmentVolume = segmentVolume * 1000;
    return segmentVolume;
                                                          } // close  volumeOccupiedSpace function
 

 int Tanker::Convert()
{
 int answer=0;
 int hectre=10000;
 int millimetres=1000 ;
  answer=millimetres / 1000;
  answer=hectre / 10000;
         return answer;
} //close Convert function
 

void Tanker::PromptDipStickLevel()
{
                                                                           cout << "Type a number: " << endl;
                                                                      cout <<"For the total amount of liquid for the tanker, then press enter:" << endl;
cin >> EnterTank;
tankAmount=VolumeOccupiedSpace(EnterTank * 0.001);
} //close PromptDipStickLevel function
 
void Tanker::PromptArea()
{
cout << "Type a number: " << endl;
cout << "To enter for the size of the paddock, then press enter: " << endl;
cin >> EnterArea;
if (EnterArea * hectre>=TotalVolume())
{
cout << "The number entered for the tank is too big! " << endl;
} //close if block
 
} //close PromptArea  function
 

         float Tanker::CalculateArea(float fertaliser, float water)
{
 float answer;
    answer =size * fertaliser * water;
   return answer;
} //close calculateArea function
 

void Tanker::Result()
{
 
totalLitersToSpray = EnterArea * hectre;
 litersToMix = totalLitersToSpray - tankAmount;
 

 cout << "Total Fertaliser Used for size of paddock: " << 0.25 * litersToMix  << " Litres " << endl;
cout << "Total water used for size of paddock: " << 0.75 *  litersToMix  << " Litres " << endl;
 

if (tankAmount>totalLitersToSpray)
 {
 cout << "There is enough mixture in the tank! " << endl;
 } //close if block
 
} //close result function                                                                                                    } //close result function