Collaboration on this lab exercise is strongly ENCOURAGED. The exercise is intended for practice, not assessment -- most people who try should get all participation points. Feel free to ask for help from, and provide help to, others. You shouldn't blindly copy solutions from one another (or from anywhere else) nor simply write code for someone else (even if you explain it as you write), but you can certainly help each other debug, give plenty of suggestions and hints, **explain** why things work or don't work, etc. If you get done early, feel free to walk around and help others.
Part 1:
Write a program that takes 2 doubles as input and outputs their sum, difference, product, and quotient. Test your program with multiple sets of inputs. Be sure to give it both double (floating point) and integer values as input for your tests.
Your output should look similar to the following example: (you should give different user input)
         Enter 2 values: 1.2 3.6Part 2:
Write a program similar to Part 1 except that it takes 2 inputs of type int instead of double. Again, test it with multiple sets of inputs (double and int input). Notice the result when you divide using int variables. Your final program for this part should also output the remainder for integer division using the modulus operator (%). Remember, integer division only happens when both operands are integer type.
Again, here is an example output
         Enter 2 values: 1 3Part 3:
Write a program that outputs whether a student passed or failed an exam. If the exam score out of 100 is 60 or higher, the student passed. If the score is below 60, the student failed. The exam score should be input by the user and an appropriate message sent to the screen.
Part 4:
Rewrite your program from Part 3 to get 3 exam scores for the student. The average of the 3 scores must be 60 or higher to pass.
Part 5:
Write a program that basically combines Part 1 and Part 2. The program should give the user the choice whether they want to use integer or double operations. Use a char type variable to store the user's choice. The comparison operators can be used with char type variables the same as with int or double type variables. For example, you can compare whether a char variable called choice is equal (==) to the char constant, 'i', using the boolean expression, (choice == 'i').
Sample run of the program: (user chooses integer operations)
         This program will output the sum, difference, product, and quotient of 2 numbers.Sample run of the program: (user chooses double operations)
         This program will output the sum, difference, product, and quotient of 2 numbers.Part 6:
Write a program to convert a temperature given in degrees Celsius to a temperature in degrees Fahrenheit using the following formula:
         Fahrenheit degree = (9 / 5) * Celsius degree + 32Here is a sample output. You should verify your program gives the same output given this input.
         Enter a temperature in degrees Celsius: 100If your program is giving incorrect output, one possible reason may be the way you wrote your arithmetic expression. 9 and 5 are integer constants. So, if you wrote them exactly the same as they appear in the formula (9 / 5), what would be the result, since this is integer division? How can you fix this? (Recall, if at least one operand is a double, the result is a double.
Part 7:
Write a program similar to Part 6 except you give the user the choice whether they want to convert from Celsius to Fahrenheit or from Fahrenheit to Celsius.
Please feel free to help your fellow labmates reach this point!!
The following exercises are for your own benefit. You are not required to do these. In fact, they may contain material not covered in class or lab yet. As such, the TAs will give priority to helping students on the previous sections.
Challenge 1:
Output the maximum and minimum of 5 values entered by the user. Use only 3 variables.
Challenge 2:
Write a program that calculates whether a given year is a leap year. A leap year is a year that is divisble by 4 except when it is divisible by 100 unless it also divisible by 400. This year is a leap year because 2004 is divisble by 4 and not by 100. The year 2000 is divisible by 100, but because it is also divisible by 400 it was also a leap year. The year 2100 will not be a leap year because it is divisible by 100 and not by 400. Hint: The modulus (%) operator would come in handy here.