{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Conditionals and Loops(1)

# Conditionals and Loops(1) - Chapter 5 Conditionals and...

This preview shows pages 1–3. Sign up to view the full content.

Chapter 5: Conditionals and Loops Lab Exercises Topics Lab Exercises Boolean expressions PreLab Exercises (in-class) The if statement Computing a Raise (in-class) The switch statement A Charge Account Statement (submit) Activities at Lake LazyDays (submit) Rock, Paper, Scissors (extra credit) Chapter 5: Conditionals and Loops 65

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Prelab Exercises Sections 5.1-5.3 1. Rewrite each condition below in valid Java syntax (give a boolean expression): a. x > y > z b. x and y are both less than 0 c. neither x nor y is less than 0 d. x is equal to y but not equal to z 2. Suppose gpa is a variable containing the grade point average of a student. Suppose the goal of a program is to let a student know if he/she made the Dean's list (the gpa must be 3.5 or above). Write an if... else... statement that prints out the appropriate message (either "Congratulations—you made the Dean's List" or "Sorry you didn't make the Dean's List"). 3. Complete the following program to determine the raise and new salary for an employee by adding if ... else statements to compute the raise. The input to the program includes the current annual salary for the employee and a number indicating the performance rating (1=excellent, 2=good, and 3=poor). An employee with a rating of 1 will receive a 6% raise, an employee with a rating of 2 will receive a 4% raise, and one with a rating of 3 will receive a 1.5% raise. // *************************************************************** // Salary.java // Computes the raise and new salary for an employee // *************************************************************** import java.util.Scanner; public class Salary { public static void main (String[] args) { double currentSalary; // current annual salary double rating; // performance rating double raise; // dollar amount of the raise Scanner scan = new Scanner(System.in); // Get the current salary and performance rating System.out.print ("Enter the current salary: "); currentSalary = scan.nextDouble(); System.out.print ("Enter the performance rating: "); rating = scan.nextDouble(); // Compute the raise -- Use if ... else ...
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern