Problem # 3 - data = scan.next();...

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

View Full Document Right Arrow Icon
import java.util.Scanner; public class EmployeeDriver { public static void main(String[] args) { double salary; double newSalary; int yearhired; String id; String initialName; String newName; String data; Boolean valid = true; Scanner scan = new Scanner(System.in); System.out.println("Enter a name for the employee"); initialName = scan.nextLine(); System.out.println("Enter a salary for the employee"); salary = scan.nextDouble(); System.out.println("Enter the year the employee was hired."); yearhired = scan.nextInt(); System.out.println("Enter the identification number for the employee."); id = scan.nextLine(); id = scan.nextLine(); Employee emp = new Employee(salary, yearhired, id, initialName); emp.writeOutput(); emp.writeOutput2(); while(valid) { valid = false; System.out.println("Would you like to change the Employee's name (y or n). ");
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: data = scan.next(); if(data.equalsIgnoreCase("y")) { System.out.println("Enter a name for the employee"); newName = scan.nextLine(); newName = scan.nextLine(); emp.setName(newName); } else if(data.equalsIgnoreCase("n")) { } else { System.out.println("Error: not a valid Entry"); valid = true; } } valid = true; while(valid) { valid = false; System.out.println("Would you like to change the Employee's salary (y or n). "); data = scan.next(); if(data.equalsIgnoreCase("y")) { System.out.println("Enter an annual salary for the employee"); newSalary = scan.nextDouble(); emp.setSalary(newSalary); } else if(data.equalsIgnoreCase("n")) { } else { System.out.println("Error: not a valid Entry"); valid = true; } } emp.writeOutput(); emp.writeOutput2(); } }...
View Full Document

This note was uploaded on 09/28/2011 for the course CS 2133 taught by Professor Rao during the Fall '10 term at Oklahoma State.

Page1 / 2

Problem # 3 - data = scan.next();...

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

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