fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. //declaring cin inputs
  8. string userName;
  9. int userMiles;
  10. int userSteps;
  11.  
  12. //declaring constant for number of steps/mile
  13. const int stepsPerMile = 2000;
  14.  
  15. //getting user's name
  16. cout << "What is the user's name?";
  17. cin >> userName;
  18. cout << endl;
  19.  
  20. //getting miles walked
  21. cout << "How many miles did " << userName << " hike today?";
  22. cin >> userMiles;
  23. cout << endl;
  24.  
  25. //getting other steps taken
  26. cout << "How many other steps did " << userName << " take today?";
  27. cin >> userSteps;
  28. cout << endl;
  29.  
  30. int stepsTakenFromMiles;
  31. int totalSteps;
  32.  
  33. stepsTakenFromMiles = userMiles * stepsPerMile;
  34. totalSteps = stepsTakenFromMiles + userSteps;
  35.  
  36. cout << userName << " took " << totalSteps << " steps throughout the day." << endl;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 4700KB
stdin
Mike
5
1000
stdout
What is the user's name?
How many miles did Mike hike today?
How many other steps did Mike take today?
Mike took 11000 steps throughout the day.