BLIND-DEV Archives

Development of Adaptive Hardware & Software for the Blind/VI

BLIND-DEV@LISTSERV.ICORS.ORG

Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Marvin Hunkin <[log in to unmask]>
Reply To:
BLIND-DEV: Development of Adaptive Hardware & Software for the Blind/VI" <[log in to unmask]>
Date:
Thu, 15 Apr 2004 16:31:35 +1000
Content-Type:
multipart/alternative
Parts/Attachments:
text/plain (4 kB) , text/html (10 kB)
    Hi.
can any one help?
i will post the code and the assignment specs below.
my code does not produce the correct output.
please take a look at the code and the assignment specs.
then e-mail me off list with any suggestions, on how to improve my program.
Cheers Marvin.



 /*
* Program: C++ Session 21 Exercise
* File Name: Paddock.cpp
*Description: Session 21 Exerciseto 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>

using namespace std;



class Tanker
{
        public:
 float r;
 float l;
 float f;
        float radius;
        float length;
        float fertaliserlevel;
 float fertaliser;
 float water;
 float size;
 float pi;
 float hectre;
float diameter;


void Title();
 float TotalVolume(float pi,  float radius, float length);
 float VolumeOccupiedSpace(float depth, float length);
 int Convert();
void PromptHectre();
void PromptFertaliser();
  float CalculateArea(float fertaliser, float water);
 void Result();
};  //close Tanker class


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


                    Tanker myTanker;

 myTanker.fertaliser=0.75;
 myTanker.water=0.25;
 myTanker.pi=3.14;
 myTanker.hectre=2000;
        myTanker.diameter=2.5;
         myTanker.Title();
                                  myTanker.PromptHectre();
                                  myTanker.PromptFertaliser();
                                                  myTanker.Result();
                                        getch();
                                        return 0;
} //close main function


 void Tanker::Title()
{
cout <<"\Welcome To Marvins Paddock " << endl;;
cout << "\nThis program asks the user to enter a number for the amount of liquid to be entered into the tanker. ";
cout << "\nAnother pprompt appears on screen, asking the user to enter a number , for the amount of area they wish to use for the paddock. ";
cout << "\nAnother prompt  appears on screen, asking the user to enter the amount of liquid which they want to use for the tanker. " ;
cout << "\nThen the total fertaliser, total water, total volume and total area used for the paddock appears on screen. ";
cout << endl;
cout << endl;
} //close title function


 float Tanker::TotalVolume(float Pi,  float Radius, float Length  )
{
float answer;
  answer = Pi * Radius * Radius * diameter;
  return answer;
} //close total Volume function

 float Tanker::VolumeOccupiedSpace(float Depth, float Length)
{
float length;
float radius;
float depth;
    float depthDivideRadius = ((radius - depth) / radius);
                  float theta = 2*acos(depthDivideRadius);
                  float surfaceArea = (radius * radius) * (theta -
sin(theta))/2;
                  float segmentVolume = surfaceArea * length;
                  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::PromptHectre()
{
float EnterArea=0.0;
cout << "Type a number: " << endl;
cout << "For the size of the farmer's paddock, then press enter: " << endl;
  cin >> EnterArea;
              } // close promptHectre function


              void Tanker::PromptFertaliser()
{
 float EnterTank=0.0;
        cout << "Type a number: " << endl;
        cout << "For the farmer's fertaliser level, then press enter: " << endl;
  cin >> EnterTank;

} //close promptFertaliser function


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


void Tanker::Result()
{
float radius;
float length;


cout << "Total Fertaliser Used: " << pi * radius * radius * length * diameter * water * fertaliser * fertaliserlevel << "Litres " << endl;

              } //close result function


Session 21 Assessment Activity

For the final exercise you are required to write a program for a farmer who has built himself a tanker trailer for his tractor so that he can spray paddocks
with a fertiliser mixture. The ratio is 3 litres of water to every litre of fertiliser concentrate. The fertiliser is sprayed on paddocks at a rate of
2000 litres per hectare.

The tank is a cylinder and lays on its side like a milk tanker. It is 2.5 metres in diameter and 4 metres long. The farmer has built a dip stick and measures
the level of liquid in the tank in millimeters. The problem that he has is working out how many litres of liquid is in the tank and how litres of fertilizer
to add to give enough to cover a paddock.

The farmer therefore wishes to enter the size of his paddocks and the current level of fertiliser in the tank into the program. And the program then calculates
for the farmer how many litres water and concentrate to be put in the tank to give the correct amount of fertiliser to cover the paddock.




ATOM RSS1 RSS2