Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C PROGRAMMING Problem: When to Set Sail? (settingsail.c) Your friend is almost ready to leave Spain to search for treasure in the Caribbean! To

IN C PROGRAMMING

Problem: When to Set Sail? (settingsail.c)

Your friend is almost ready to leave Spain to search for treasure in the Caribbean! To make sure that the maximum number of crew members make it through the trip safely, your friend will carefully select which months to travel the ocean during.

In this program, you will examine a file of weather data. Ask the user for the name of this file. Then, ask the user for the temperature range that their crew sails best in. Calculate the percentage of days in each month that fall into that range. Pirates are not the most skilled at recording data, so a file of weather data may not contain information for every day in every month. Instead, calculate the percentage by dividing the number of days in range by the number of days that there is data for.

The month with the highest percentage is the month that your friend should pick to begin their journey for treasure!

Arrays are not expected to be a part of this program, except for the name of the input file. Do not attempt to store all the values in the file in your program.

Input Specification

1. The lower bound temperature will be an integer between 0 and 80

2. The upper bound temperature will be an integer higher than the lower bound and less than 120

3. The file name will be a string less than 30 characters in length

Input File Specification There will be 12 months of weather data available. Since months may not have complete information, each month will begin with a header number (n) to indicate how many temperatures are available for that month. The month will then have n real numbers representing the temperature for each day.

Output Specification

Output to the screen. Show the user the percentage of days in range for each month. Then, print the best month for your friend to begin their voyage.

Month X: YY.Y percent of days in range.

You should leave for the Caribbean in month Z!

Output Sample

Below is a sample output of running the program. Note that this sample is NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above. In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold. (Note: When you actually run your program no bold or italics should appear at all. These are simply used in this description for claritys sake.)

Tell me about your crews preferred temperature for sailing:

What is the coldest temperature they can sail in?

60

What is the hottest temperature they can sail in?

80

Please enter the name of the weather data file:

temperatures.txt

Month 1: 93.3 percent of days in range.

Month 2: 20.0 percent of days in range.

Month 3: 58.1 percent of days in range.

Month 4: 100.0 percent of days in range.

Month 5: 100.0 percent of days in range.

Month 6: 50.0 percent of days in range.

Month 7: 64.5 percent of days in range.

Month 8: 9.7 percent of days in range.

Month 9: 60.0 percent of days in range.

Month 10: 100.0 percent of days in range.

Month 11: 93.3 percent of days in range.

Month 12: 83.9 percent of days in range.

You should leave for the Caribbean in month 4!

temperature.txt :

15 63.4 66.1 67.2 58.5 61.9 68.2 65.3 70.0 72.9 71.8 70.1 70.3 69.5 66.1 70.8 5 56.5 57.1 55.0 58.0 66.2 31 54.0 53.2 46.6 47.4 56.7 62.6 53.7 57.5 60.7 65.7 66.0 67.8 62.3 58.3 55.6 60.2 62.8 70.5 72.9 71.0 61.8 61.6 71.2 73.0 68.6 56.6 51.2 56.0 59.7 62.1 69.2 20 72.3 72.8 71.5 71.3 69.4 64.6 68.7 70.6 72.5 72.2 78.0 78.6 77.4 75.4 69.3 77.3 74.2 75.7 79.9 72.2 30 72.8 70.9 72.7 73.0 71.8 69.6 61.3 71.7 73.4 76.6 77.5 77.3 76.1 71.5 72.4 73.7 75.0 77.8 77.1 77.3 73.5 74.7 78.2 78.8 78.2 73.6 69.3 76.9 76.0 78.5 30 79.2 80.3 78.9 78.7 75.8 75.6 78.4 80.0 78.1 80.7 79.4 79.9 81.9 82.2 82.0 81.0 80.8 81.3 82.4 80.7 78.0 82.3 77.7 81.6 81.7 80.7 79.0 80.4 79.1 78.2 31 76.4 76.2 78.1 78.9 80.4 81.8 82.4 82.4 82.1 80.8 80.3 78.7 78.2 77.5 77.5 78.1 79.3 78.6 77.3 77.6 80.1 79.3 78.6 79.7 79.9 81.6 78.0 79.6 79.9 83.0 82.2 31 81.1 81.9 81.6 80.0 82.7 81.2 83.6 83.0 82.0 82.3 83.6 83.1 83.6 82.5 81.7 82.2 82.8 82.3 81.8 83.0 83.1 80.4 81.8 80.2 79.0 79.9 80.8 80.3 81.6 82.6 81.2 30 79.9 78.8 79.6 80.9 81.3 80.6 77.8 80.9 81.7 81.8 81.8 79.7 79.7 82.5 81.7 80.2 80.5 78.1 79.3 78.7 78.7 79.1 77.1 77.5 76.7 80.6 76.0 76.8 78.0 77.8 31 79.1 78.5 78.7 79.5 79.5 79.2 77.1 78.9 75.5 74.6 74.9 75.8 76.1 76.0 73.2 76.9 77.4 78.4 79.0 76.5 79.8 79.6 76.8 67.8 68.3 67.5 67.1 68.5 71.8 74.1 75.3 30 77.1 71.3 67.2 68.7 73.2 74.2 70.1 70.8 70.5 72.0 72.1 71.1 64.8 62.7 68.1 70.7 75.1 75.9 73.8 71.7 73.1 73.9 73.7 67.9 67.1 72.7 69.7 50.6 59.5 64.5 31 66.1 66.1 65.8 69.6 71.4 74.1 73.2 72.8 73.1 71.8 72.0 65.9 60.0 69.7 70.9 59.3 57.1 58.4 59.1 65.8 72.7 75.0 74.7 68.6 58.8 64.6 65.2 70.1 73.4 65.2 62.3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

9. Describe the characteristics of power.

Answered: 1 week ago

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago