I am doin a project for class that involves c++ programming. I am having trouble gettin it started though i posted the link below to the problem. Can anyone give suggestions to how i should approach this?
THanks alot in advance
Duoas 1,025 Postaholic Featured Poster
Your professor has done an extraordinary job of giving you concrete information to work with. Just take it one step at a time.
Look through the functions he has asked you to write and pick the one you think will be easiest. Do it first. Work from easiest to hardest and it will help you organize your thoughts better.
When you get some code post it and any errors you are getting when you compile or run it.
Good luck.
jamesny89 0 Newbie Poster
heres the code ive written so far
#include <iostream>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
void programDescription ();
// Gives description of program
double getValidAltitude ();
// Gets valid altitude from user
// returns value to main fucntion
double getMachNumber ();
// Gets mach number for user
double ambientPressure (double& amTemp);
//
double ambientTemp (double& valAlt);
//
double pressureRatio (double& valMach, double& amPress);
//
double compressibleQ (double& totalPress, double& amPress);
//
bool keepGoing ();
//
double displayResults (double& compQ);
//
const string WELCOME ( " This program is desinged to give you compressible Q based on the altitude and mach number that you give" );
int main ()
{
programDescription ();
do
{
getValidAltitude ();
getMachNumber ();
ambientTemp();
ambientPressure ();
pressureRatio ();
compressibleQ ();
keepGoing () ;
} while keepGoing ();
displayResults ();
}
void programDescription ()
{
cout << WELCOME << endl;
system ("pause") ;
system ("cls") ;
}
double getValidAltitude ()
{
double valAlt;
cout << "Please enter your altitude: " << endl;
cin >> valAlt;
while ((valAlt < 0) || (valAlt > 100000))
{
cout << "Invalid altitude try again: " << endl;
cin >> valAlt ;
}
return valAlt;
}
double getMachNumber ()
{
double valMach;
cout << " Please enter mach number: " << endl;
cin >> valMach ;
while ((valMach > 20) || (valMach < 0))
{
cout << " Invalid Mach Number, try again: " << endl;
cin >> valMach;
}
return valMach;
}
double ambientTemp (double& valAlt)
{
double amTemp;
if ( valAlt <= 36089)
{
amTemp = 518.688 - 3.56613e-03/valAlt ;
}
else if ( (valAlt >= 36090) || (valAlt <= 65616))
{
amTemp = 389.99 ;
}
else if ((valAlt >= 65617) || (valAlt <= 100000))
{
amTemp = 389.99+5.4864e-04/(valAlt-65617) ;
}
return amTemp;
}
double ambientPressure (double& amTemp, double& valAlt)
{
double amPress;
if (valAlt <= 36089)
{
amPress = 14.696*(amTemp/518.688,5.2561) ;
}
else if ((valAlt >= 36089) || (valAlt <= 100000))
{
amPress = 3.2825 * e(-((valAlt-36089)/(20806))) ;
}
}
bool keepGoing ()
{
char answer(Y, y, N, n) ;
cout << "Would you like to continue(Y/N): " << endl;
cin >> answer ;
if ((answer == n) || (answer == N))
}
double presseureRatio (double& valMach)
{
double pressRat;
pressRat = ((1)+((1.4-1)/(2))*(valMach*valMach)),((1.4)/(1.4-1)) ;
}
double compressibleQ( double& amPress, double& pressRat)
{
double totPress, compQ;
totPress = pressRat * amPress ;
compQ = totPress-amPress ;
}
void displayResults (double& compQ, double& valAlt, double& valMach)
{
cout << " Based on an altitude of "
<< valAlt
<< " and a mach number of "
<< valMach
<< " your compressible q is equal to "
<< compQ
<< endl;
}
the only compilation errors i got were
function takes 0 arguments
too many intializers
i am also tryin to use e as a log in the ambient pressure but i dont think its working
any suggestions??
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
>>function takes 0 arguments
What line number? Pay close attention to the parameters of the function prototypes at the top of the program and the parameters (or lack of parameters) passed in lines 44 thru 50 of your program.
Duoas 1,025 Postaholic Featured Poster
There is no such function as e(). You want to #include <cmath>
and use exp(). See here for more.
You need to define some variables in main() and use them. Like Ancient Dragon said, you are not using your functions correctly. For example, getValidAltitude() returns a value. So you should have something like: double altitude;
altitude = getValidAltitude();
Likewise, some functions take arguments as well.
You have a very good start.
Salem 5,199 Posting Sage
> any suggestions??
Yes, don't write so much code without pressing "compile", or running the result.
Step 1 would be
int main () {
return 0;
}
Compile and run. It should be trivial right?
Step 2, add ONE function.
#include <iostream>
using namespace std;
void programDescription ();
int main ()
{
programDescription ();
return 0;
}
void programDescription ()
{
cout << WELCOME << endl;
system ("pause") ;
system ("cls") ;
}
Again, compile and run.
DO NOT add more code until you've got the current round working to your satisfaction, otherwise you end up in the current position of having so many errors you've no idea what to do with, and just dump the whole mess on a forum for someone else to fix.
Until you've got the confidence to increase the interval, I would suggest no more than 10 lines at a time between compile/test. For sure you need to test each new function as it is complete.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.