The homework is to re-write the previous program so that the user does not need to enter any freezing point information. Only the salinity of the water.  Thefull question in the picture Code in C Previous Program #include #include int main(void) { /* Declare variables. */ double a, f_a, b, f_b, c, f_c; /* Get user input from the keyboard. */ printf("Use ppt for salinity values. \n"); printf("Use degrees F for temperatures. \n"); printf("Enter first salinity and freezing temperature: \n"); scanf("%lf %lf",&a,&f_a); printf("Enter second salinity and freezing temperature: \n"); scanf("%lf %lf",&c,&f_c); printf("Enter new salinity: \n"); scanf("%lf",&b); /* Check that salinity is between first two points. Note the order of a and c is not known, so I am checking for both orders (a>c and ab)&&(b>c)))) { printf("\nThe new salinity is not between the salinity" " of the two provided freezing temperatures."); return(1); } /* Use linear interpolation to compute new freezing temperature. */ f_b = f_a + (b-a)/(c-a)*(f_c - f_a); /* Print new freezing temperature. */ printf("New freezing temperature in degrees F: %0.1f \n",f_b); return 0;/* Exit program. */ } /*–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

The homework is to re-write the previous program so that the user does not need to enter any freezing point information. Only the salinity of the water. 

Thefull question in the picture

Code in C

Previous Program

#include <stdio.h>
#include <math.h>
int main(void)
{
/* Declare variables. */
double a, f_a, b, f_b, c, f_c;
/* Get user input from the keyboard. */
printf("Use ppt for salinity values. \n");
printf("Use degrees F for temperatures. \n");
printf("Enter first salinity and freezing temperature: \n");
scanf("%lf %lf",&a,&f_a);
printf("Enter second salinity and freezing temperature: \n");
scanf("%lf %lf",&c,&f_c);
printf("Enter new salinity: \n");
scanf("%lf",&b);
/* Check that salinity is between first two points. Note the order of a and c is not known, so I am checking for both orders (a>c and a<c). I will exit the program with a code 1 if this check fails. */
if (!(((a<b)&&(b<c))||((a>b)&&(b>c))))
{
printf("\nThe new salinity is not between the salinity" " of the two provided freezing temperatures.");
return(1);
} /* Use linear interpolation to compute new freezing temperature. */
f_b = f_a + (b-a)/(c-a)*(f_c - f_a);
/* Print new freezing temperature. */
printf("New freezing temperature in degrees F: %0.1f \n",f_b);
return 0;/* Exit program. */

}
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/

HW 6: Salinity and Freezing Points Revisited
The homework is to re-write the previous program so that the user does not need to enter any freezing
point information. Only the salinity of the water. Basically, you will be embedding the information in
the Sal vs FP table into the program. You can use the switch statement or embedded if statements. The
valid range of salinity for this program is 0-35. If the user enters a salinity outside of that range, you
should re-ask for the information (use a while or a do loop).
Run the program at the following points (you can use the previous version answer as your test cast –
salinity of 17 should be 30.4.
salinity 4
salinity 23
salinity 30
salinity 38
Please utilize the Lecture Problem 3) material in creating your code.
Material below is some material from that the lecture. And
Salinity (ppt)
Freezing Temperature (°F)
some comments on how to approach the problem. Be sure to
O (fresh water)
32
follow the design steps (problem statement, I0 block, Hand
example (previously done), program decomposition, pseudo
10
31.1
code / flow chart. There are multiple ways of solving the
20
30.1
problem. I would think about the chart below as being divided
24.7
29.6
into 7 regions (see labels I've added to the chart. Inside each
inner region an extrapolation equation is valid and
30
29.1
straightforward to program (done last week). The issue is to get
35
28.6
the correct information into the extrapolation for the region of
interest.
Freezing Temperature of Seawater
Region 0
40
Sal < 0
Region 1
35
Region 2
Region 3
Region 5
30
Region 6
Sal >35
Region 4
25
20
10
15
20
25
30
35
Salinity (ppt)
Temperature, °F
Transcribed Image Text:HW 6: Salinity and Freezing Points Revisited The homework is to re-write the previous program so that the user does not need to enter any freezing point information. Only the salinity of the water. Basically, you will be embedding the information in the Sal vs FP table into the program. You can use the switch statement or embedded if statements. The valid range of salinity for this program is 0-35. If the user enters a salinity outside of that range, you should re-ask for the information (use a while or a do loop). Run the program at the following points (you can use the previous version answer as your test cast – salinity of 17 should be 30.4. salinity 4 salinity 23 salinity 30 salinity 38 Please utilize the Lecture Problem 3) material in creating your code. Material below is some material from that the lecture. And Salinity (ppt) Freezing Temperature (°F) some comments on how to approach the problem. Be sure to O (fresh water) 32 follow the design steps (problem statement, I0 block, Hand example (previously done), program decomposition, pseudo 10 31.1 code / flow chart. There are multiple ways of solving the 20 30.1 problem. I would think about the chart below as being divided 24.7 29.6 into 7 regions (see labels I've added to the chart. Inside each inner region an extrapolation equation is valid and 30 29.1 straightforward to program (done last week). The issue is to get 35 28.6 the correct information into the extrapolation for the region of interest. Freezing Temperature of Seawater Region 0 40 Sal < 0 Region 1 35 Region 2 Region 3 Region 5 30 Region 6 Sal >35 Region 4 25 20 10 15 20 25 30 35 Salinity (ppt) Temperature, °F
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY