LabPracticum1_Ocean_Salinity_R3.docx EGR 112 Practice Practicum 1 Name:________________ Ocean Salinity Guidelines: 1. Put your name at the top of this document and return it at the end of the exam. 2....

page, 3, page 1 has the info., c code


LabPracticum1_Ocean_Salinity_R3.docx EGR 112 Practice Practicum 1 Name:________________ Ocean Salinity Guidelines: 1. Put your name at the top of this document and return it at the end of the exam. 2. Materials provided for reference: - ASCII Table, Order of Operations Table, printf handout, math.h and string.h function lists 3. You are allowed to use your textbook and notes for the exam. This includes submitted homework, labs, and in class assignments. You may not use any other electronic reference material. 4. With about ~10 minutes remaining, you must wrap up what you are doing, and upload your source code to the Blackboard Assignment Manager. 5. Take a deep breath – you can do it! Problem & Instructions: The salinity of the water in the ocean is a function of the water temperature, ocean depth and current speed. Additionally, the salinity is highly dependent upon the particular ocean that is under consideration. Your task today will be to write a program that will serve as an ocean salinity calculator. Given the water temperature T in degrees Kelvin, ocean depth D in meters and current speed C in meters per second, the water salinity S in parts-per-hundred (pph) is given as ? = 16633 × ??? 10 5 4 ?+1( ) ?/223.1 3 ?+1 + ? where R is the reference salinity for a particular body of water (i.e., a particular ocean). Your task today is to create a program to compute S in pph. You are to query the user to enter the water temperature T in degrees Celsius (you will need to convert T temporarily to degrees Kelvin to compute S), ocean depth D in meters and current speed C in meters per second. Assume that the user enters the data correctly and in the correct units (no error checking on the data format is necessary). Furthermore, you are to input a single character that will be used to indicate the reference salinity R for a particular body of water. The choices for reference salinity are the following: P for the Pacific Ocean, A for the Atlantic Ocean, I for the Indian Ocean, S for the Southern Ocean and R for the Arctic Ocean. Allow the user to enter either upper or lower case letters. Furthermore, in the event that the user does not enter a correct character denoting one of the given oceans, you are to assume that they meant the Pacific Ocean. Based upon the character the user enters, you will need to choose the correct value for the reference salinity R. Reference Data: Table 1: Ocean Reference Salinity in pph Ocean Reference Salinity (pph) Pacific 3.0 Atlantic 3.5 Indian 4.0 Southern 2.1 Arctic 2.3 ????(°?) = ????(℃) + 273. 15 EGR 112 Practice Practicum 1 - 2 - EGR 112 Practice Practicum 1 Follow these detailed instructions: Tier 1 Requirements (Minimum Deliverables to receive a ‘C’ on the exam): 1. Pay attention to the compiler messages as you go along. Also turn it in on time. Penalties are as follows: Each type of error -10 Each type of warning -5 Each minute late -10 1. (15 pts) Start from the provided template code. Include any additional libraries that are necessary. Use good formatting and style. Match your output to the examples given. 2. (15 pts) Include the usual comment block, including the program name, author, date, class, professor, description, and notes. Include descriptive comments throughout. 3. (10 pts) Prompt user and scan in values for temperature (in Celsius), depth, and speed. 4. (20 pts) Display the requested output for temperature, depth, and speed. Your output statement must display as shown in the examples (note spelling, punctuation, newlines, and lack of trailing zeros): 5. (10 pts) Convert the temperature from Celsius to Kelvin and output as shown. Tier 2 Requirements (Minimum Deliverables to receive a ‘B’ on the exam): 6. (5 pts) Prompt user and scan in character for ocean name. a. The user indicates the ocean choice by entering one of five characters. Assume that the user may enter upper case or lower case letters. In the event that the user does not enter one of the five letter choices but something else, use the reference salinity for the Pacific Ocean. Otherwise, based on their entry, use the proper value for R. 7. (10 pts) Assign the correct reference salinity and print the ocean name. a. Write out the name of the Ocean (Pacific, Atlantic, Southern, Arctic or Indian) that corresponds to the character the user entered. In the case where the user’s ocean choice did not match any of the available options, write out Unknown, using Pacific for that field. Tier 3 Requirements (Minimum Deliverables to receive an ‘A’ on the exam): 8. (10 pts) Calculate the salinity using the given equation. 9. (5 pts) Display the salinity and output as shown. - 3 - EGR 112 Practice Practicum 1 Example Input/Output: Below are example test cases with expected output in order to help you validate your code. The input data is listed as T, D, C followed by the ocean choice character. Overview: Based on the following data: temperature of ____ degrees C (___ K), depth of ____ m, and current speed of ____ m/s in the ____________ Ocean, the water salinity is _____ parts-per-hundred. Test set #1: Input: -2.3 411 2.1 r Output: Based on the following data: temperature of -2.3 degrees C (270.85 K), depth of 411 m, and current speed of 2.1 m/s in the Arctic Ocean, the water salinity is 12.607 parts-per-hundred. Test set #2: Input: 22.787 1000 0.1224 I Output: Based on the following data: temperature of 22.787 degrees C (295.937 K), depth of 1000 m, and current speed of .1224 m/s in the Indian Ocean, the water salinity is 21.267 parts-per-hundred. Test set #3: Input: 31.5 2.75 12.9875 x Output: Based on the following data: temperature of 31.5 degrees C (304.65 K), depth of 2.75 m, and current speed of 12.9875 m/s in the Unknown (using Pacific) Ocean, the water salinity is 4.579 parts-per-hundred. - 4 - EGR 112 Practice Practicum 1 NOTE: Your code will be tested with other input/output scenarios when graded. Hardcoding these numbers will result in significant loss of points. - 5 - EGR 112 Practice Practicum 1 Outline: //Include Header (Tier 1) //Include correct preprocessor directives #include #include int main() { double T; // Temp (C) double D; // Depth (m) double C; // Current Speed (m/s double R; // Reference Salinity (pph) double S; // S: Salinity (pph) char ocean; // Single character for ocean (user entry) // Request user entry for temp, depth, and current speed. (Tier 1) // Request user entry for ocean. (Tier 2 – save for later) // Convert temp to Kelvin (Tier 1): // Output temp, depth, and speed (Tier 1): // Assign reference salinity (Tier 2): // Output ocean name (Tier 2): // Calculate the salinity (Tier 3): // Output the salinity (Tier 3): return 0; } - 6 -
Feb 23, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here