Need help with a C++ program Write a C++ program that helps a person determine how long they can hike for under various conditions on a given supply of water. Your program should prompt the user to enter how much water they can carry in liters. Then, for each of the following conditions, print out how many hours the user can hike for. - moderate temperature, moderate difficulty: 1/2 liter per hour - moderate temperature, high difficulty: 3/4 liter per hour - high temperature, moderate difficulty: 1 and 1/2 liters per hour - high temperature, high difficulty: 1 and 3/4 liters per hour SAMPLE OUTPUT Hello! Welcome to the Hiking Water Calculator! How many liters of water can you carry? 8 OK. Here is how long you can hike for on 8 liters of water under the following conditions: moderate temperature, moderate difficulty: 16 hours moderate temperature, high difficulty: 10.6666666 hours high temperature, moderate difficulty: 5.3333333 hours high temperature, high difficulty: 4.5714285 hours. Here is what I did, but it looks like there is a problem with liters_of_water = liters_of_water / 0.5/0.75/1.5/1.75. When runnung the program using 8 as the user input, it not working. /* This program is to help a person determine how long they can hike for under various conditions on a given supply of water.*/ std:: cout << " Hello! Welcome to the Hiking Water Calculator! \n\n"; // The user needs to enter how much water he can carry in liters. double liters_of_water; std:: cout << " How many liters of water can you carry? "; std:: cin >> liters_of_water; std:: cout <<"\n"; /* Here, the calculator will the user an estimate of how many liters of water he can use for a short period of time (hours) based on conditions*/ std:: cout << " OK. Here is how long you can hike for on " << liters_of_water << " liters of water under the following conditions:"; // First condition: here's how many hours the user can hike for 1/2 liter of water per hour. liters_of_water = liters_of_water /0.5 ; std:: cout << "\n\n"; std:: cout << " Moderate temperature, moderate difficulty: " << liters_of_water << " hours"; // For second condition, here's how many hours the user can hike for 3/4 liter per hour. liters_of_water = (liters_of_water) / 0.75; std:: cout << "\n\n"; std:: cout << " Moderate temperature, high difficulty: " << liters_of_water << " hours"; liters_of_water = (liters_of_water) / 1.5; std:: cout << "\n\n"; // For the third condition, here's how many hours the user can hike for 1 and 1/2 liters per hour. std:: cout << " High temperature, moderate difficulty: " << liters_of_water << " hours"; std:: cout << "\n\n"; // For the fourth condition, here's how many hours the user can hike for 1 and 3/4 liters per hour. liters_of_water = (liters_of_water) / 1.75; std:: cout << " High temperature, high difficulty: " << liters_of_water << " hours"; return 0; }
Need help with a C++
Write a C++ program that helps a person determine how long they can hike for under various conditions on a given supply of water.
Your program should prompt the user to enter how much water they can carry in liters. Then, for each of the following conditions, print out how many hours the user can hike for.
- moderate temperature, moderate difficulty: 1/2 liter per hour
- moderate temperature, high difficulty: 3/4 liter per hour
- high temperature, moderate difficulty: 1 and 1/2 liters per hour
- high temperature, high difficulty: 1 and 3/4 liters per hour
SAMPLE OUTPUT
Hello! Welcome to the Hiking Water Calculator!
How many liters of water can you carry? 8
OK. Here is how long you can hike for on 8 liters of water under the following conditions:
moderate temperature, moderate difficulty: 16 hours
moderate temperature, high difficulty: 10.6666666 hours
high temperature, moderate difficulty: 5.3333333 hours
high temperature, high difficulty: 4.5714285 hours.
Here is what I did, but it looks like there is a problem with liters_of_water = liters_of_water / 0.5/0.75/1.5/1.75. When runnung the program using 8 as the user input, it not working.
/* This program is to help a person determine how long they can hike for under various conditions on a given supply of water.*/
std:: cout << " Hello! Welcome to the Hiking Water Calculator! \n\n";
// The user needs to enter how much water he can carry in liters.
double liters_of_water;
std:: cout << " How many liters of water can you carry? ";
std:: cin >> liters_of_water;
std:: cout <<"\n";
/* Here, the calculator will the user an estimate of how many liters of water he can use for a short period of time (hours) based on conditions*/
std:: cout << " OK. Here is how long you can hike for on " << liters_of_water << " liters of water under the following conditions:";
// First condition: here's how many hours the user can hike for 1/2 liter of water per hour.
liters_of_water = liters_of_water /0.5 ;
std:: cout << "\n\n";
std:: cout << " Moderate temperature, moderate difficulty: " << liters_of_water << " hours";
// For second condition, here's how many hours the user can hike for 3/4 liter per hour.
liters_of_water = (liters_of_water) / 0.75;
std:: cout << "\n\n";
std:: cout << " Moderate temperature, high difficulty: " << liters_of_water << " hours";
liters_of_water = (liters_of_water) / 1.5;
std:: cout << "\n\n";
// For the third condition, here's how many hours the user can hike for 1 and 1/2 liters per hour.
std:: cout << " High temperature, moderate difficulty: " << liters_of_water << " hours";
std:: cout << "\n\n";
// For the fourth condition, here's how many hours the user can hike for 1 and 3/4 liters per hour.
liters_of_water = (liters_of_water) / 1.75;
std:: cout << " High temperature, high difficulty: " << liters_of_water << " hours";
return 0;
}
Step by step
Solved in 4 steps with 2 images