C++ Problem
Write a program to convert mph to kph. Use the approximation that 100 mph = 161 kph
#include
using namespace std; double convertToMPH(int paceInMin, int paceInSec); //represents pace in minutes and seconds per mile and returns the speed in mph double convertToMPH(double kph); //represents in kph and returns the speed in mph //1 mile = 1.61 km //1 km = 1000m //d=vt, v=d/v int main() { int paceInMin; int paceInSec; double kph; double total; // ************* Variable added ************* cout << \"Please enter an integer to represent your pace in minutes: \"; cin >> paceInMin; cout << \"Please enter an integer to represent your pace in seconds: \"; cin >> paceInSec; // ************ Pass total to the function ************ total = convertToMPH(paceInMin, paceInSec); // ********* Now you can manipulate the variable any way you\'d like... ************ cout << \"Your speed is \" << total << \" miles per hour.\" << endl; if (total < 4) { cout << \"Really? \"<< total << \" miles per hour? \ You must be the six million dollar man!\"<< endl; } else { if (total >10) { cout << \"Come on! My grand mother can run faster than \" << total << \" miles in an hour.\" << endl; } else { cout << \"Nice pace!!\" << endl; } } // ************* continue with program here *************** cout << \"\ Please enter your speed in kph: \"; cin >> kph; total = convertToMPH(kph); cout << \"Your speed in mph is \" << total << endl; return 0; } double convertToMPH(int paceInMin, int paceInSec) { return(60 / (paceInMin + paceInSec / 60.)); }; double convertToMPH(double kph) { return (kph / 1.61); };