I'm having issues with this program; here's the description of what I have to do:
The Galactic Research and Development Division has discovered a number of new small lifeforms species inside the trunks of trees native to the exoplanet Caliente-116. They are carefully studying these creatures and recording the several characteristics so that these can be compared to lifeforms found on exoplanet Caliente-103. The exoplanet has 12 continents labeled with a letter, A through L. We have been asked to produce a program that records the data gathered on the lifeforms and computes the density of the lifeform.
The program should ask the user to enter:
the lifeform number (lifeforms are number starting with 116001),
letter indicating which continent on the exoplanet the tree was from
the height or length in centimeters,
the weight in grams, and
number of liters displaced when the creature was placed in the lifeforms status tank.
The program should then calculate and display the density (kg/m3) for the lifeform.
The formulas used are as listed in the program below. I'm not sure what I'm doing wrong, can someone help please?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
using namespace std;
int main()
{
double lifeFormNumber = 0.0;
double lifeFormWeight = 0.0;// In grams
double lifeFormHeight = 0.0;// In centermeters
double lifeFormDisplacement = 0.0;
char continent;
cout << "Please enter the lifeform number: ";
cin >> lifeFormNumber;
cout << "Please enter the continent letter where the tree was found: ";
cin >> continent;
cout << "Please enter the lifeform's height: ";
cin >> lifeFormHeight;
cout << "Please enter the lifeform weight: ";
cin >> lifeFormWeight;
double weight = lifeFormWeight / 1000;
double displacement = lifeFormDisplacement / 1000;
double lifeFormDensity = weight / displacement;
cout << "\nThe lifeform weight is: " << weight << " kg." << endl;
cout << "The lifeform displacement is: " << displacement << " m^3." << endl;
cout << "The density of this life form is: " << lifeFormDensity << " kg/m^3." << endl;
cout << "Please press ENTER to end program.";
cin.sync();
getchar();
return 0;
}
|