Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program is C Exercise #1: a. Using Geany, write a C program that prompts and asks the user for two assignment marks (al and a2)

image text in transcribedimage text in transcribedProgram is C

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 (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' to test that the program separates the 'B' and 'C' grades. tinue 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 t1 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 = 0) && (30 % 10

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

3. How has Starbucks changed since its early days?

Answered: 1 week ago