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; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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;
}

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Algebraic Expressions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education