Explain these codes import java.text.DecimalFormat; import java.util.Scanner; public class Main { private static DecimalFormat df2 = new DecimalFormat("#.00"); public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println(); System.out.print("\tEnter Name : "); String emp_name =input.nextLine(); System.out.print("\tPress F for Full Time or P for Part Time : "); char job_criteria =input.next().charAt(0); char select = Character.toUpperCase(job_criteria); System.out.println(); if (select == 'F') { System.out.print("\t------ Full Time Employee ----- "); System.out.println(); System.out.print("\tEnter Basic Pay : "); double basic_pay = input.nextDouble(); FullTimeEmployee emp = new FullTimeEmployee(); emp.setName(emp_name); emp.setMonthlySalary(basic_pay); System.out.println("\n"); System.out.println("\tName : " + emp.getName()); System.out.println("\tWage : " + df2.format(emp.getMonthlySalary())); System.out.println("\n"); } else if (select == 'P') { System.out.print("\t------ Part Time Employee ----- "); System.out.println("\n"); System.out.print("\tEnter Rate Per Hour and No. of Hours Worked Seperated By Space : "); double rate_per_hour = input.nextDouble(); int no_hours_work2 = input.nextInt(); PartTimeEmployee emp = new PartTimeEmployee(); emp.setName(emp_name); emp.setRatePerHour(rate_per_hour); emp.setHoursWorked(no_hours_work2); System.out.println("\tName : " + emp.getName()); System.out.println("\tWage : " + df2.format(emp.getWage())); System.out.println("\n"); } else { System.out.println("\n"); System.out.print("\tInvalid Option. Please Try Again"); } System.out.print("\tEnd of Program"); System.out.println("\n"); input.close(); } } class Employee { private String name; public void setName(String name) { this.name = name; } public String getName() { return name; } } class PartTimeEmployee extends Employee { private double ratePerHour; private int hoursWorked; private double wage; public void setWage() { wage = hoursWorked * ratePerHour; } public double getWage() { setWage(); return wage; } public void setRatePerHour(double rate) { ratePerHour = rate; } public void setHoursWorked(int hours) { hoursWorked = hours; } } class FullTimeEmployee extends Employee { private double monthlySalary; public void setMonthlySalary(double salary) { monthlySalary = salary; } public double getMonthlySalary() { return monthlySalary; } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Explain these codes

import java.text.DecimalFormat;
import java.util.Scanner;

public class Main
{
    private static DecimalFormat df2 = new DecimalFormat("#.00");

    public static void main(String[] args) 
    {
        Scanner input = new Scanner(System.in);
        System.out.println();
        System.out.print("\tEnter Name : ");
        String emp_name =input.nextLine();
        System.out.print("\tPress F for Full Time or P for Part Time : ");
        char job_criteria =input.next().charAt(0);
        char select = Character.toUpperCase(job_criteria);
        System.out.println();

        if (select == 'F') {
            System.out.print("\t------ Full Time Employee ----- ");
            System.out.println();
            System.out.print("\tEnter Basic Pay :  ");
            double basic_pay = input.nextDouble();
            FullTimeEmployee emp = new FullTimeEmployee();
            emp.setName(emp_name);
            emp.setMonthlySalary(basic_pay);
            System.out.println("\n");
            System.out.println("\tName    :  " + emp.getName());
            System.out.println("\tWage    :  " + df2.format(emp.getMonthlySalary()));

            System.out.println("\n");

        } 
        else if (select == 'P') 
        {
            System.out.print("\t------ Part Time Employee ----- ");
            System.out.println("\n");
            System.out.print("\tEnter Rate Per Hour  and No. of Hours Worked  Seperated By Space     :  ");
            double rate_per_hour = input.nextDouble();
            int no_hours_work2 = input.nextInt();

            PartTimeEmployee emp = new PartTimeEmployee();
            emp.setName(emp_name);
            emp.setRatePerHour(rate_per_hour);
            emp.setHoursWorked(no_hours_work2);
            System.out.println("\tName    :  " + emp.getName());
            System.out.println("\tWage    :  " + df2.format(emp.getWage()));

            System.out.println("\n");
        } else {
            System.out.println("\n");
            System.out.print("\tInvalid Option. Please Try Again");
        }

        System.out.print("\tEnd of Program");
        System.out.println("\n");
        input.close();

    }
}
class Employee
{
    private String name;

    public void setName(String name)
    {
        this.name = name;
    }

    public String getName()
    {
        return name;
    }
}
class PartTimeEmployee extends Employee
{
    private double ratePerHour;
    private int hoursWorked;
    private double wage;

    public void setWage()
    {
        wage = hoursWorked * ratePerHour;
    }

    public double getWage()
    {
        setWage();
        return wage;
    }

    public void setRatePerHour(double rate)
    {
        ratePerHour = rate;
    }

    public void setHoursWorked(int hours)
    {
        hoursWorked = hours;
    }
}

 

class FullTimeEmployee extends Employee
{
    private double monthlySalary;

    public void setMonthlySalary(double salary)
    {
        monthlySalary = salary;
    }

    public double getMonthlySalary()
    {
        return monthlySalary;
    }
}

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY