Conditionals and Loops(1)

Conditionals and - Chapter 5 Conditionals and Loops Lab Exercises Topics Boolean expressions The if statement The switch statement Lab Exercises

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 .
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/31/2010 for the course CPSC 1301 taught by Professor Khan,s during the Spring '08 term at Columbus State University.

Page1 / 6

Conditionals and - Chapter 5 Conditionals and Loops Lab Exercises Topics Boolean expressions The if statement The switch statement Lab Exercises

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online