Question

You will be writing a multiclass user management system using the java. Create a program that implements a minimum of four cl

My Java code from last assignment:

Previous Java code:

public static void main(String args[]) {

// While loop set-up

boolean flag = true;

while (flag) {

Scanner sc = new Scanner(System.in);

// Ask user to enter employee number

System.out.print("Enter employee number: ");

int employee_number = sc.nextInt();

// Ask user to enter last name

System.out.print("Enter employee last name: ");

String last_name = sc.next();

// Ask user to enter number of hours worked

System.out.print("Enter number of hours worked: ");

int hours_worked = sc.nextInt();

while (true) {

if (hours_worked >= 0) {

break;

} else {

System.out.print("Hours worked must be greater or equal to 0. Please enter hours again. ");

hours_worked = sc.nextInt();

}

// Ask user to enter hourly rate

System.out.print("Enter hourly rate: ");

double hourly_rate = sc.nextDouble();

while (true) {

if (hourly_rate >= 0) {

break;

} else {

System.out.print("Hourly rate must be greater or equal to 0. Please enter hours again. ");

hourly_rate = sc.nextDouble();

}

}

// Ask user to enter state tax

System.out.print("Enter state tax: ");

double state_tax = sc.nextDouble();

while (true) {

if (state_tax >= 0) {

break;

} else {

System.out.print("State tax must be greater or equal to 0. Please enter again. ");

state_tax = sc.nextDouble();

}

}

// Ask user to enter federal tax rate

System.out.print("Enter federal tax rate: ");

double federal_tax_rate = sc.nextDouble();

while (true) {

if (federal_tax_rate >= 0) {

break;

} else {

System.out.print("Federal tax rate must be greater or equal to 0. Please enter again. ");

federal_tax_rate = sc.nextDouble();

}

}

// User inputs are calculated and then printed

System.out.println("Employee number :" + employee_number);

System.out.println("Employee Last Name :" + last_name);

System.out.println("Number of hours worked :" + hours_worked);

System.out.println("Hourly rate :" + hourly_rate);

System.out.println("State tax :" + state_tax);

System.out.println("Federal tax Rate :" + federal_tax_rate);

double gross = (hours_worked * hourly_rate);

System.out.println("Groll pay :" + gross);

double net = gross - (gross * state_tax) - (gross * federal_tax_rate);

System.out.println("Net pay :" + net);

sc.nextLine();

// Ask user to enter either yes or no

System.out.println("Would you like to enter the second employees information ?");

String option = sc.nextLine();

String option1 = "";

// all letters will be converted to upper case

option1 = option.toUpperCase();

// Y or YES will be set as true, else false

if ((option1.equals("Y")) || (option1.equals("YES"))) {

flag = true;

} else if ((option1.equals("N")) || (option1.equals("NO"))) {

System.out.println("enter 0 to exit");

int number = sc.nextInt();

// entering 0 will exit the system

if (number == 0) {

flag = false;

Please have the above four classes and do not use array.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int eid=0;
import java.util.Scanner.*;
class Employee
{
int EmployeeId;
String FirstName,MiddleInitial,LastName;
Date DateOfEmployement;
public Employee()
{
EmployeeId=++eid;
Scanner s = new Scanner(System.in);
System.out.println("Enter Employee Details : ");
System.out.println("Enter your First name : ");
FirstName = s.getString();
System.out.println("Enter your Middle Initial : ");
MiddleInitial = s.getString();
System.out.println("Enter your Last Name : ");
LastName = s.getString();
System.out.println("Enter the date of Employement :");
DateOfEmployement = s.getDate();
}
void display()
{
System.out.println("First Name : " + FirstName);
System.out.println("Middle Initial : " + MiddleInitial);
System.out.println("Last Name : " + LastName);
System.out.println("Date of Employement : " + DateOfEmployement);
}
}
class EmployeeType extends Employee
{
void payroll()
{
int pay;
pay = month * 100;
System.out.println(pay);
}
}
class Address
{
String StreetAddress,city,state;
int zipcode;
Address()
{
Scanner sca = new Scanner(System.in);
System.out.println("Enter Street Address : ");
StreetAddress = sca.nextString();
System.out.println("Enter City : ");
city = sca.nextString();
System.out.println("Enter State");   
state = sca.nextString();
System.out.println("Enter Zip Code");
zipcode = sca.nextInt();
}
void display()
{
System.out.println("Street Address : " + StreetAddress);
System.out.println("City : " + city);
System.out.println("State : " + state);
System.out.println("Zip Code : " + zipcode);
}
}
class Contact
{
String email;
long phone;
Contact()
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter Email Address : ");
email = scan.nextString();
System.out.println("Enter Phone no : ");
phone = scan.nextInt();
}
void display()
{
System.out.println("Email Address : " + email);
System.out.println("Phone Number : " + phone);
}
}
public class EmployeeDetails
{
public static void main(String [] args)
{
EmployeeType salaried = new EmployeeType();
EmployeeType hourly = new EmployeeType();
Scanner sc = new Scanner(System.in);
System.out.println("What would you like to do ?");
System.out.println("1.Register Employees");
System.out.println("2.View Employee Details");
System.out.println("3.Calculate Salary");
int ch;
while(1)
{
ch = sc.nextInt();
switch (ch)
{
case 1:
System.out.println("How many employees do you like to register ?");
int no,i;
no = sc.nextInt();
for(i=0;i<n;i++)
{
Employee e = new Employee();
Address add = new Address();
Contact c = new Contact();
}
break;
case 2:
System.out.println("Employee Details : ");
for(i=0;i<n;i++)
{
Employee e = new Employee();
e.display();
Address add = new Address();
add.display();
Contact c = new Contact();
c.display();
}
break;
case 3:
salaried.payroll();
horly.payroll();
break;
}
}
}
}
  
  
  

Add a comment
Know the answer?
Add Answer to:
My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • public static void main(String[] args) {         System.out.println("Welcome to the Future Value Calculator\n");         Scanner sc...

    public static void main(String[] args) {         System.out.println("Welcome to the Future Value Calculator\n");         Scanner sc = new Scanner(System.in);         String choice = "y";         while (choice.equalsIgnoreCase("y")) {             // get the input from the user             System.out.println("DATA ENTRY");             double monthlyInvestment = getDoubleWithinRange(sc,                     "Enter monthly investment: ", 0, 1000);             double interestRate = getDoubleWithinRange(sc,                     "Enter yearly interest rate: ", 0, 30);             int years = getIntWithinRange(sc,                     "Enter number of years: ", 0, 100);             System.out.println();            ...

  • This is for a java program public class Calculation {    public static void main(String[] args)...

    This is for a java program public class Calculation {    public static void main(String[] args) { int num; // the number to calculate the sum of squares double x; // the variable of height double v; // the variable of velocity double t; // the variable of time System.out.println("**************************"); System.out.println(" Task 1: Sum of Squares"); System.out.println("**************************"); //Step 1: Create a Scanner object    //Task 1. Write your code here //Print the prompt and ask the user to enter an...

  • I need this java program to contain methods that do some of the work that can...

    I need this java program to contain methods that do some of the work that can be modularized. It must logically be the same as this loop program but instead the logic will be modularized into Java Methods. Continue to take input for every employee in a company, and display their information until a sentinel value is entered, that exits the loop and ends the program. import java.util.Scanner; public class SalaryCalc { double Rpay = 0, Opay = 0; void...

  • Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args)...

    Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args) { displayWelcomeMessage(); // create the Scanner object Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { // generate the random number and invite user to guess it int number = getRandomNumber(); displayPleaseGuessMessage(); // continue until the user guesses the number int guessNumber = 0; int counter = 1; while (guessNumber != number) { // get a valid int from user guessNumber...

  • Convert into pseudo-code for below code =============================== class Main {    public static void main(String args[])...

    Convert into pseudo-code for below code =============================== class Main {    public static void main(String args[])    {        Scanner s=new Scanner(System.in);        ScoresCircularDoubleLL score=new ScoresCircularDoubleLL();        while(true)        {            System.out.println("1--->Enter a number\n-1--->exit");            System.out.print("Enter your choice:");            int choice=s.nextInt();            if(choice!=-1)            {                System.out.print("Enter the score:");                int number=s.nextInt();                GameEntry entry=new GameEntry(number);   ...

  • Explain this java code, please. import java.util.Scanner; public class Program11 { public static void main(String[] args)...

    Explain this java code, please. import java.util.Scanner; public class Program11 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); final int maxSize = 128; String[] titles = new String[maxSize]; int[] lengths = new int[maxSize]; int numDVDs = 0; String op; op = menu(stdIn); System.out.println(); while (!op.equalsIgnoreCase("q")) { if (op.equalsIgnoreCase("a")) { if (numDVDs < maxSize) numDVDs = addDVD(titles, lengths, numDVDs, stdIn); } else if (op.equalsIgnoreCase("t")) searchByTitle(titles, lengths, numDVDs, stdIn);    else if (op.equalsIgnoreCase("l")) searchByLength(titles, lengths, numDVDs, stdIn); System.out.println('\n');...

  • import java.util.Scanner; public class TempConvert { public static void main(String[] args) { Scanner scnr = new...

    import java.util.Scanner; public class TempConvert { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); //ask the user for a temperature System.out.println("Enter a temperature:"); double temp = scnr.nextDouble(); //ask the user for the scale of the temperature System.out.println("Is that Fahrenheit (F) or Celsius (C)?"); char choice = scnr.next().charAt(0); if(choice == 'F') { //convert to Celsius if given temperature was Fahrenheit System.out.println(temp + " degrees Fahrenheit is " + ((5.0/9) * (temp-32)) + " degrees Celsius"); } else {...

  • import java.util.Scanner; public class MPGMain {    public static void main(String[] args)    {       ...

    import java.util.Scanner; public class MPGMain {    public static void main(String[] args)    {        Scanner input = new Scanner(System.in);               Mileage mileage = new Mileage();               System.out.println("Enter your miles: ");        mileage.setMiles(input.nextDouble());               System.out.println("Enter your gallons: ");        mileage.setGallons(input.nextDouble());               System.out.printf("MPG : %.2f",mileage.getMPG());           } } public class Mileage {    private double miles;    private double gallons;    public double getMiles()...

  • import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables...

    import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables int creditScore; double loanAmount,interestRate,interestAmount; final double I_a = 5.56,I_b = 6.38,I_c = 7.12,I_d = 9.34,I_e = 12.45,I_f = 0; String instructions = "This program calculates annual interest\n"+"based on a credit score.\n\n"; String output; Scanner input = new Scanner(System.in);// for receiving input from keyboard // get input from user System.out.println(instructions ); System.out.println("Enter the loan amount: $"); loanAmount = input.nextDouble(); System.out.println("Enter the credit score: "); creditScore...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT