Sunday, August 2, 2009

C++ - Visual C++ Program this for me please.?

// Program Shell3 reads miles and hours and prints miles


// per hour.





#include %26lt;iostream.h%26gt;


#include %26lt;iomanip.h%26gt;





/* FILL IN the function prototype for GetData */





int main ()





{








float miles;


float hours;


float milesPerHour;








/* FILL IN code to call function GetData */





milesPerHour = miles / hours;





cout %26lt;%26lt; miles %26lt;%26lt; hours %26lt;%26lt; milesPerHour %26lt;%26lt; endl;








return 0;








}





//************************************...





/* FILL IN the function heading for GetData */








{





/* FILL IN Code to prompt for miles and hours */


/* FILL IN Code to read miles and hours */








}

C++ - Visual C++ Program this for me please.?
/*FILL IN $20 in my pocket and then I will do it*/








edit : OK, $10








EDIT EDIT : Of course you will get errors if you don't fill it with real C++ Syntax...duh!
Reply://You might want to do some error checking, if required, to make sure correct numbers are entered!


void getData(float %26amp;miles, float %26amp;hours)


{


cout %26lt;%26lt; "Miles? ";


cin %26gt;%26gt; miles;





cout %26lt;%26lt; "Hours? ";


cin %26gt;%26gt; hours;


}





...WeirdB is right, your really not learning if someone else is doing it for you! You might regret this on the test, but hopefully you may heed this warning in the future. Good Luck!
Reply:miles, hours and milesPerHour should be initialized so they can further used, put initial zeros to them and 1 to hours coz if GetData() didn't modify them you won't get any errors in your arithmatics, and double check the values when they return from GetData() .. keep the money just tell me if it works
Reply:You haven't given any information on the errors, so I'd have to guess. You have a set of braces outside the int main() scope that isn't part of a function. I can see that being an error.


Keep your 20$ and just give me best answer ;)
Reply:1) Do your own homework


2) Hint: this question has already been answered on this site. Search for it.

orchid cactus

No comments:

Post a Comment