You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we will start using branching on the second iteration!
Exercises
EvenOdd
In a file called EvenOdd.java, create an application that prompts the user to enter an integer.
Pass the integer to a method that determines weather the integer is even or odd and returns a boolean value.
In the main method, display whether the number is even or odd.
ShadyRestRoom
In a file called ShadyRestRoom.java create an application that determines the price for a room.
Ask the user to choose 1 for a queen bed, 2 for a king bed or 3 for a king bed and pullout couch.
The output must reflect the input and the price of the room: R500 for a queen bed,
R700 for king bed and R900 for a king bed and a pullout couch.
If the user inputs an invalid choice display a corresponding message and set the price to R0.
Now ask the user to specify 1 for a lake view or 2 for a park view, but only ask them if the bed size entry is valid.
Add R100 to the price of any room with a lake view.
If the input value for view is invalid display a corresponding message and set the price of the room as lake view.
CellPhoneService
In a file called CellPhoneService.java, create an application that prompts the user for the max monthly amount they need for talking minutes, text messages and gigabytes of data.
Display a recommendation of the best plan for the users needs.
A user who needs less than 500 minutes, and no text messages or data should buy (Plan A at R150 per month).
A user who needs less than 500 minutes and any text messages should buy (Plan B at R210 per month).
A user who needs 500 or more minutes and no data should buy either (Plan C for up to 100 text messages at R90 per month) or (Plan D for 100 text messages or more at R115 per month).
A use who needs any data should buy (Plan E for up to 3 gigabytes at R 150 per month) or (Plan F for 3 gigabytes or more at R230 per month).
NumbersDemo
In a class called NumbersDemo.java, whose main method holds two integer variables.
Prompt the user for the values of those variables.
Pass each variable to the methods, displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared().
Create each method to perform the task its name implies.
Percentages
In a class called Percentages.java, whose main method holds two double variables.
Prompt the user for the values of those variables.
Pass both variable to a method named computePercentages() that displays the two values and the value of the first number as a percentage of the second one.