We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
LAB 5: EXERCISE
Total = 100 marks
Task 1: Determining body temperature using if-else statement [25 marks] You are required to build an application which is used to alert its user either he/she has fever or not. A thermometer is the device which will be feeding the human temperature to your application and in response the application will tell if the temperature is safe or not. An oral temperature of 37.8 degrees Celsius or higher indicates the fever.
Initially suppose that you need to feed the temperature information manually and your program output should look like this:
Enter thermometer reading in Celsius: 39
Please take care, you have got fever.
Enter thermometer reading in Celsius: 37.2
No worries, you are fine.
Task 2: Maximum number finder using if statements [25 marks]
Create a program that takes in 4 real numbers and outputs the highest amongst them onto the screen. Make sure that your program works correctly for both negative and positive integers.
Create a program that takes in the coefficients of a quadratic equation and uses them to calculate its roots. Make sure to print “No solution” if the equation does not have any solutions. −𝑏±√𝑏 2 −4𝑎𝑐 Use 𝑥 = to calculate the roots of the given equation. The expression 𝑏 2 − 4𝑎𝑐 is important 2𝑎 to determine the nature of the roots. Whenever it gives negative value, solution does not exist and roots are considered imaginary.
Task 4: Simple Calculator using if-else statements [25 marks]
For this task, you have to create a calculator which takes in two real numbers. The program then prompts the user for the mathematical operation that he/she wishes to perform. Only consider addition, subtraction, multiplication, and division. After performing the appropriate operation, the program prints the result on the screen.