Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help! During the lab: PART I: PROGRAMMING EXERCISES Exercise #1: a. Using Geany, write a C program that prompts and asks the user for
Please help!
During the lab: PART I: PROGRAMMING EXERCISES 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 (ti 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 (printf) 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. f. 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: 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. Exercise #3: a. Using Geany, ask the user for a warship class by a letter ('S', 'C', 'D', 'F' and 'A'). Use a switch statement to display the warship class name (S for Submarine, C for Cruiser, D for Destroyer, F for Frigate and A for Aircraft Carrier). Display a message that the ship is unknown if the user enters any other letter. (Note: accept also the lowercase version of the letters) Exercise #4: a. The National Earthquake Information Centre has asked you to write a program implementing the following decision table to characterize an earthquake based on its Richter scale number. Richter scale number (n) n > 5.0 5.0 En > 5.5 5.5 En > 6.5 6.5Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started