Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6826741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:11:02+00:00 2026-05-26T22:11:02+00:00

Create an array class for Employee which will reserved 7 elements. The class will

  • 0

Create an array class for Employee which will reserved 7 elements. The class will have 2 data fields, a constructor and a get method for each field. The employee constructor requires two arguments: an employee number and a salary. You may use any looping statements.

I started it but I don’t know how to finish it:

import java.util.Scanner;

public class Employee {
    int [] array= new int [8];
    private int empNum;
    private double empSal;
    void Test1(int e, double s){
        empNum = e;
        empSal = s;
    }

    public int getEmpNum(){
        return empNum;
    }
    public double getSalary(){
        return empSal;
    }

    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        System.out.printf("Please enter your employee number:");
        int e = sc.nextInt();
        System.out.printf("Please enter your salary:");
        double s= sc.nextInt();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:11:02+00:00Added an answer on May 26, 2026 at 10:11 pm

    Assuming you’ll want 7 employees (at most), don’t care for unique empNum (if you do you can add equalsTo() overriden function).
    Also assuming you do all your additions once in the main function, with no special logic.

    import java.util.Scanner;
    import java.util.ArrayList;
    import java.util.List;
    
    public class Employee {
        private int empNum;
        private double empSal;
    
        public Employee(int e, double s){
            empNum = e;
            empSal = s;
        }
    
        public int getEmpNum(){
            return empNum;
        }
    
        public double getSalary(){
            return empSal;
        }
    
        public static void main(String[]args){
            List<Employee> employeeList= new ArrayList<Employee>();
    
            while (employeeList.size() < 7) {
                Scanner sc = new Scanner(System.in);
                System.out.printf("Please enter your employee number:");
                int e = sc.nextInt();
                System.out.printf("Please enter your salary:");
                double s= sc.nextDouble();
                employeeList.add(new Employee(e, s));
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to create an array of a class containing two values,
I have a class Agent , which contains a pointer (array) of class ValueContainer
I have a problem. I'm trying to create an array of different class objects
What i'm trying to do is create a template array class that will store
I have a method that returns an array of custom class objects that are
I need to create an extension method to array class, but this extension method
I am trying to create an array of class objects taking an integer argument.
I was trying to create an extension that could slice any array-like class (since
I'm trying to create a Quicksort base class using VB.NET, taking it an array
I created a simple class in C++ which has a private dynamic array. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.