Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please code in C? Exercise #2: a. Modify the program written for Exercise #1 to add the following rule: If either test mark ti or

please code in C?
image text in transcribed
image text in transcribed
image text in transcribed
Exercise #2: a. Modify the program written for Exercise #1 to add the following rule: "If either test mark ti or t2 is less than 50, change the grade to an 'F'.". now check your program with this set of data: 80 60 45 80. If should be an 'F' with the new rule. Homework: On paper (no computer needed), do the following programming (write the code by hand as you would on a test or an exam). 8. Write a program that interacts with the user like this: (1) Carbon monoxide (2) Hydrocarbons (3) Nitrogen oxides (4) Nonmethane hydrocarbons Enter pollutant number>> 2 Enter number of grams emitted per mile>> 0.35 Enter odometer reading>> 40112 Emissions exceed permitted level of 0.31 grams/mile. Use the table of emissions limits below to determine the appropriate message. First 50,000 Miles Second 50,000 Miles carbon monoxide hydrocarbons nitrogen oxides nonmethane hydrocarbons 3.4 grams/mile 0.31 grams/mile 0.4 grams/mile 0.25 grams/mile 4.2 grams/mile 0.39 grams/mile 0.5 grams/mile 0.31 grams/mile Show your homework to your lab assistant at the beginning of next week's lab. If you wish, you may try your solution with the computer to see if you got the correct solution (no need to show the computer version). PART 1: PROGRAMMING EXERCIS Exercise #1: a. Using Geany, write a C program that prompts and asks the user for two assignment marks (al and a2) and two test marks (t1 and t2). All four variables are integer variables and are in % (out of 100). You program should display the four marks properly lalebed to check if the input has been successful. b. Next, calculate and display the average of the four marks. C. The program should continue to add on to what you have written by using an if statement to assign the letter 'A' to a char variable named "grade" if the average is greater than or equal to 80. The program should print out the grade as a single letter using %c to output the variable "grade". Repeat running your program with different input data, and be sure to input the marks so that at least one trial case gives an 'A'. Afterwards change the output (print) statement so that a "label" is produced. Recall that this is so that when looking at the screen you will know what the number you see is meant to represent. (eg: "The grade is A", as opposed to just 'A'.) d. The program should then expand this into an if/else statement to assign the letter 'A' to a char variable named grade if the average is greater than or equal to 80, or 'B' if the average is less than 80. Test this with the marks 80 85 75 85 and then run the program again with marks 75 65 70 75. e. The program should then use an if statement inside the else branch to additionally separate out the averages less than 80. If the average is less than 80 (all marks in this else part will be) the inner if statement will assign the grade as 'B' if the average is greater than or equal to 70 and 'C' if the average is less than 70. This time, create your own sets of four marks to test that the program separates the 'B' and 'C' grades. Continue the use of if statements in the else sections as you create them to separate grades into 'C' vs 'D' ('C' is greater than or equal to 60, but of course still less than 70; 'D' is for marks less than 60 but more than or equal to 50; and 'F if the mark is less than 50. Again, check this with several of your own sets of four marks. g. Modify and Check your program with example grades so that the output looks like this: Enter Assignments Grades: 80 70 Enter Test Grades: 60 70 The average is: 70% The letter grade is: B Make sure the averages and letter grades are correct for every set of grades and have your program checked by the TA. Exercise #2

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

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions