Dana Vrajitoru
C101 Computer Programming

C101/I210 Homework 4

Due date: Wednesday, February 12, 2020.

Objective: To use conditionals in Java.

Ex. 1. Temperature qualifier

In this project, we will input a temperature in Fahrenheit and will output a message stating what it feels like to us.

Create a Java project in Eclipse and call it hw4. Create a class in this project called TempTest and containing the main method. Write your name, course, semester, and homework number at the top as a comment.

Declare an integer variable to hold the value of the temperature and repeat the usual steps to declare a Scanner in your program. Input the value from the user with an appropriate message and using the method nextInt().

Next, add a multi-case conditional (at least 4 cases) for the value of the temperature, and output a message in each case showing what it feels like, such as "It's colder than Hoth", "It's cold outside", "It's just fine", "It's kind of warm", "Too warm to leave a pet outside", and so on. For example, the first message could be for a temperature less than -10, the next one between -10 and 50, the third one for a temperature between 50 and 80, and so on. Feel free to write your own messages (qualifiers) and to set your own ranges for the temperature, as long as you organize them in ascending order.

Turn in:

Upload the lab and homework .java files: Greeting.java and TempTest.java, to Canvas in Assignments - Homework 4.