public class Assignment6
{
public static void main(String[] args)
{
Scanner console = new Scanner(System.in);
String choice;
char command;
// Create a new Employee object
System.out.print("Enter name of the employee? ");
String name = console.next();
System.out.print("Enter salary for " + name + "? ");
double salary = console.nextDouble();
System.out.print("Enter number of years for " + name + "? ");
int years = console.nextInt();
Employee e1 = new Employee(name, salary, years);
Employee e2 = new Employee("Bond:70000:20");
// print the menu
printMenu();
do
{
// ask a user to choose a command
System.out.println("\nPlease enter a command or type ?");
choice = console.next().toLowerCase();
command = choice.charAt(0);
switch (command)
{
case 'a': // print the info for each employee
System.out.println(e1.toString());
System.out.println(e2.toString());
break;
case 'b': //raise employee's salary
System.out.println("Enter the amount of raise:
");
double raise = console.nextDouble();
e1.raiseSalary(raise);
e2.raiseSalary(raise);
System.out.println(e1);
System.out.println(e2);
break;
case 'c': //increment the number of years by 1
e1.setYears();
/*-------------------------------------------------------------------------
// AUTHOR: Ryan Nelson
// FILENAME: Employee.java
// SPECIFICATION: Implementing Employee class
// YOUR Lab Letter and Name of the TA for your Closed lab
// FOR: CSE 110- Assignment 6 1:30
// TIME SPENT: 7 days
* 1) The value cannot be printed because it doesn't exist. Beyond an error
message it could only print "null"
* 2) one is assigning the variable to a new integer, while the other one
assigns it as a character
*/
import java.util.*;
import java.text.*;
e2.setYears();
System.out.println("Year has been added.");
break;
case 'd': //find who is making more
Employee who = e1.makesMore(e2);
System.out.println(who.getName() + " is making
more.");
break;
case 'e': //number of employees
System.out.println("They are " +
Employee.getNumEmployees()+ " employees.");
break;
case '?':
printMenu();
break;
case 'q':
break;
default:
System.out.println("Invalid input");
}
} while (command != 'q');
}// end main
public static void printMenu()
{
System.out.print("\nCommand Options\n"
+ "-----------------------------------\n"
+ "'a': prints info \n"
+ "'b': raise salary\n"
+ "'c': increment the years of
experience\n"
+ "'d': who makes more\n"
+ "'e': number of employees\n"
+ "'?': Displays the help menu\n"
+ "'q': quits\n");
} // end of the printMenu method
}
Powered by TCPDF (www.tcpdf.org)