Answer to Question #226977 in Java | JSP | JSF for Princess

Question #226977
You have to design your own Java console application about any valid problem that your

application must solve. Your solution can include solving a business problem, a new idea or even a

game. Your application must make use of concepts such as arrays, loops, inheritance, constructors

and information hiding. Output must be shown in the form of a report using the console.

in your solution, make use of as many concepts, and components dealt with in this course, but

pay special attention to the following learning units.

Learning Unit 1. Advanced arrays

Learning Unit 2: Introduction to inheritance
1
Expert's answer
2021-08-18T06:51:46-0400


package employee;


import java.util.Scanner;
public class Employee {
private String name;
private int id;
public Employee(String n, int i){
    name = n;
    id = i;
}
public String getName(){
    return name;
}
 public int getId(){
     return id;
 }
    public static void main(String[] args) {
       System.out.println("How many employees do want to process their details");
       Scanner input = new Scanner(System.in);
       int number = input.nextInt();
       Payment [] emp = new Payment[number];
       System.out.println("Enter the details for 10 employees");
       for(int i=0; i<number; i++){
           System.out.println("Employee  "+(i+1));
           System.out.println("Enter employee id");
           int id = input.nextInt();
           System.out.println("Enter employee name");
           String name = input.next();
           System.out.println("Enter employee salary");
           float sal = input.nextFloat();
           
           emp[i]  = new Payment(sal, name, id);
       }
       System.out.println("\nThe employees details are:\n\n");
       for(int i=0; i<number; i++){
           System.out.println("Employee  "+(i+1));
           emp[i].display();
       }
       
       
    }
    
}
class Payment extends Employee{
    private float salary;
   
    Payment(float sal, String n, int i){
        super(n,i);
        salary = sal;
        
    }
    void display(){
        System.out.printf("Employee Name: \t%s\n Employee ID:\t%d"
                + "\n Employee Salary %f   ", getName(),getId(),getSalary());
    }
    public float getSalary(){
        return salary;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS