Lab on if statements and switch statement (chapter 4) Prepare an algorithm for Project 3, p. 141 before lab. Part 1. The if statement has the form: if (condition) { statement1; statement2; ... } In this case, the dependent statements in curly braces execute only when the condition is true; they do not execute when the condition is false. If there is just one dependent statement, the curly braces can be omitted. The parentheses around conditions are required. Conditions have the form (expression rel-op expression) where each "expression" can be a variable, constant value, or general expression. rel-op is a relational operator and is one of the familiar comparison symbols: <, <=, >, >=, == (equal to), and != (not equal). Sample conditions are (x <= y) "x less than or equal y" (x != y + z) "x not equal to y plus z" (m % n == 0) "the remainder of m divided by n is zero" -- this is a way of testing whether n is a divisor of m Assignment: Write an if statement that you could add to the coins problem that displays the message "Congratulations, you are a super saver" if the amount of dollars in the coin collection is over $10. if ( Part 2. if statements with else clause have the form: if (condition) { // "true" statements go here. ... } else { // "false" statements go here. ... } In this case, the "true" statements execute when the condition is true and the "false" statements execute when the condition is false. The same rules as before apply with respect to the need for curly braces and parentheses. Assignment: Assume the following lines to read data into the projectile project (#3, p. 141) where rad_or_degree is type char and angle is type double. printf("Enter R for radians and D for degrees: "); scanf("%c", &rad_or_degree); printf("Enter angle: "); scanf("%lf", &angle); Next, write an if statement that defines theta (type double) to have the same value as angle if the character read was R. The if statement should call function convert_to_radian (provided by a friend of yours) to convert the value of angle to radians and store it in theta if the first character read was not R. The pseudocode for your if statement is: if angle value is in radians // theta is same as angle else // convert angle to radians and store the result in theta. Write the actual C if statement below. if ( Part 3: To make this a little more robust, change your condition so that it handles either 'R' or 'r' in rad_or_degree by using the logical operator || (or). For example ( x < y || x == 0) is true if x is less than y or x is zero. Notice that you cannot write this condition as (x < y || 0). Also test whether rad_or_deg is 'D' or 'd' (for degree) and display an error message if it is not. pseudocode: if angle value is in radians // theta is same as angle else if angle value is in degrees // convert angle to radians and store the result in theta. else // display an error message and set theta to -1. The else clause sets theta to -1 to indicate that invalid data was encountered. Write the C statements here: if ( Part 4. There is also a switch statement that your program can use to "make decisions" or select one alternative from several. The switch statement has the form: switch (expression) { case value1: case value2: // statements for value1 and value2 go here. break; case value3: // statements for value3 go here. break; default: // statements when expression does not match any of the values } where "expression" can be a variable or general expression. value1, value2, and value3, are literal constants which are possible values of "expression" (examples of literal constants: - 0, 15, -99, 7.453, 'A', 'a'). Assignment: write a switch statement that works the same way as the if statement you just wrote for the projectile problem. switch(rad_or_degree) { } Outside assignment: Write a function that incorporates the if statement you wrote for part 3. Write a main function that reads an angle in degrees or radians and calls this function to calculate the value of theta to use in the statements that calculate time and height. Make sure your function returns the angle value in radians or -1 if the angle cannot be computed. Write a second function that incorporates the switch statement you wrote for part 4. You should be able to call it using the same main function as above. Verify that the program gives the same results as it did using the function that has an if statement. Write and use a function in the coins problem that displays one of three messages: Super saver - if the amount is $100 or more, Good saver - if the amount is $50 or more Beginning saver - if the amount is $10 or more Start saving now - if the amount is less than $10.