Assignment 6 Implementing Employee class...
Assignment_6_Implementing_Employee_class.docx-AUTHOR: // FILENAME: Employee.java // SPECIFICATION:
Showing 1-2 out of 3
Assignment 6 Implementing Employee class.docx-AUTH...
Assignment_6_Implementing_Employee_class.docx-AUTHOR: // FILENAME: Employee.java // SPECIFICATION:
Assignment 6 Implementing Employee ...
Assignment_6_Implementing_Employee_class.docx-AUTHOR: // FILENAME: Employee.java // SPECIFICATION:
Page 1
/
*------------------------------------------------------------------------
-
// AUTHOR:
// 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.*;
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;


Page 2
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();
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
}


Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
Yale University
Yale_University
School:
demo
Course:
Great resource for chem class. Had all the past labs and assignments
Leland P.
Santa Clara University
Introducing Study Plan
Using AI Tools to Help you understand and remember your course concepts better and faster than any other resource.
Find the best videos to learn every concept in that course from Youtube and Tiktok without searching.
Save All Relavent Videos & Materials and access anytime and anywhere
Prepare Smart and Guarantee better grades

Students also viewed documents