Subject: | |
From: | |
Reply To: | BLIND-DEV: Development of Adaptive Hardware & Software for the Blind/VI" < [log in to unmask]> |
Date: | Tue, 11 May 2004 14:46:53 +1000 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Hi.
could anyone please help me.
i am stuck at this moment.
doing my c programming assignment.
things are not working properly.
am i just a dummy?
please look at my code.
i will post it below.
i do not want people to do the assignment, just give me pointers on how to
fix the problems i have with my code.
any gentle pointers in the right direction to get my program working.
please send any solutions, or hints to me.
as soon as possible.
cheers Marvin.
/*
* Program: Tank
* FileName: Tank.cpp
* Description: Session 21 Exercise
* Author: Marvin Hunkin
* Date Created: Monday May 10 2004 9:18 am
* Version: 1.00
*/
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
using namespace std;
class Tank
{
private:
float length;
float diameter;
public:
Tank(float length=4.0, float diameter=2.5);
float GetAmountInTank(float dipstickLevel);
float GetTotalCapacity();
}; //close Tank Class
int main()
{
cout.setfl(ios::fixed);
cout.precision(2);
Tank myTank;
myTank.GetAmountInTank(float dipstickLevel);
myTank.GetTotalCapacity();
cout << " Welcome To Marvin's Tank " << endl;
cout << endl;
cout << endl;
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 << "Ask the user to enter an amount of mixture to be sprayed for the
paddock. " << endl;
cout << "The total amount of mixture and the total amount of area sprayed
is displayed on screen. " << endl;
float dipstick;
cout << " Enter amount of mixture into the Tank: " << endl;
cin >> dipstick;
float area;
cout << "Enter amount of area to be sprayed: " << endl;
cin >> area;
cout << " Total Mixture Used: " << " Litres " << endl;
cout << " Total Area Sprayed: " << GetTotalCapacity() << " Hectres " <<
endl;
char answer;
cout << " Do you want to enter more data into the tank (y / n)? " << endl;
cin >> answer;
while (answer=='y')
{
cout << " Enter amount of mixture into the Tank: " << endl;
cin >> dipstick;
cout << "Enter amount of area to be sprayed: " << endl;
cin >> area;
cout << " Total Mixture Used: " << " Litres " << endl;
cout << " Total Area Sprayed: " << GetTotalCapacity() << " Hectres " <<
endl;
cout << " Do you want to enter more data into the tank (y / n)? " << endl;
cin >> answer;
} //close while loop
return 0;
} //close main
Tank::Tank(float len, float dia)
{
length = len;
diameter = dia;
} //close Tank constructor
Tank::GetAmountInTank(float dipstickLevel)
{
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
Tank::GetTotalCapacity()
{
totalCapacity = pi * radius * radius * length;
return totalCapacity ;
} //close GetTotalCapacity function
|
|
|