Hello all -
I've read C++ for Dummies, and I'm working my way through Accelerated C++ based on the advice of this board.
I created this app from scratch but it's rough, I'm hoping for suggestions on how to improve it. I've got some database, music, and Windows projects in mind using Visual C++.Net after I get the hang of basic programming with DevC++.
Thanks in advance - JM
Code:// Pace Calculator // Input Minutes and Seconds run // as well as mileage // Output is pace per mile and miles per hour #include<iostream> #include<cstdlib> // say what standard-library names we use using std::cin; using std::endl; using std::cout; int main() { // print program purpose cout<<"Pace Calculator"<<endl<<endl; // ask for the minutes cout<<"Please enter minutes run "; // read minutes int minutes = 0; cin>>minutes; // and seconds cout<<"and seconds "; int seconds = 0; cin>>seconds; // ask for mileage cout<<endl; cout<<"What was the mileage? "; double mileage = 0; cin>>mileage; //Do the math for pace per mile double TotSeconds = 0; TotSeconds = minutes * 60 + seconds; double PaceSeconds = 0; PaceSeconds = TotSeconds/mileage; int PaceMinutes = 0; PaceMinutes = TotSeconds/mileage/60; PaceSeconds = PaceSeconds - PaceMinutes * 60; // Print pace per mile cout<<endl; cout<<"Pace per mile was "<<PaceMinutes<<":"<<PaceSeconds<<endl; // Calculate MPH double MPH = 0; MPH = 60*60 / (TotSeconds/mileage); // Print MPH cout<<endl<<"which is "<<MPH<<" MPH"<<endl; cout<<endl; system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks


