EmployeeDriver

EmployeeDriver - valid = false System.out.println"Would you like to change the Employee's name(y or n" data = scan.next

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

View Full Document Right Arrow Icon
//Matt Hergenrether //CS 2133 //February 25, 2009 import java.util.Scanner; public class EmployeeDriver { public static void main(String[] args) { //declaring variables double salary; double newSalary; int yearhired; String id; String initialName; String newName; String data; Boolean valid = true; //brings in user input 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(); //error in java: without second statement the program does not wait for user input. //initiates object and sends data to class Employee Employee emp = new Employee(salary, yearhired, id, initialName); emp.writeOutput(); emp.writeOutput2(); while(valid) //allows user to modify name
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: { valid = false; System.out.println("Would you like to change the Employee's name (y or n). "); 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) //allows user to modify salary { 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

EmployeeDriver - valid = false System.out.println"Would you like to change the Employee's name(y or n" 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