4 Replies - 912 Views - Last Post: 02 October 2019 - 07:06 PM Rate Topic: -----

#1 makeitrain   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-October 19

I'm trying to use the array

Posted 02 October 2019 - 05:19 PM

I'm trying to get create a loop that will let the user enter the first, last name, and pay so I can later calculate the payment in another loop. I'm not sure I'm doing the loop correctly and would like some ideas. I've tried to display the output of the loop but it doesn't display it.

 Employee[] empArray = new Employee[numberOfEmployees];

            Employee employee = new Employee();

            for (int employeecounter = 0; employeecounter < numberOfEmployees; employeecounter++)
            {
                empArray[employeecounter] = new Employee();
                Console.Write($"enter the first name of the employee{employeecounter}: ");
                empArray[employeecounter].FirstName = Console.ReadLine();
                Console.Write($"enter the last name of the employee{employeecounter}:  ");
                empArray[employeecounter].LastName = Console.ReadLine();
                empArray[employeecounter].HourlyRate = PromptForDouble("enter the hour pay rate for employee:", Employee.MIN_HOURLY_RATE, Employee.MAX_HOURLY_RATE);
               



            }


Is This A Good Question/Topic? 0
  • +

Replies To: I'm trying to use the array

#2 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 3001
  • View blog
  • Posts: 11,551
  • Joined: 03-December 12

Re: I'm trying to use the array

Posted 02 October 2019 - 06:46 PM

Quote

03 Employee employee = new Employee();


This isn't required outside of the loop.

Quote

I've tried to display the output of the loop but it doesn't display it.


What does that mean? You mean it doesn't ask for input?
Was This Post Helpful? 0
  • +
  • -

#3 makeitrain   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-October 19

Re: I'm trying to use the array

Posted 02 October 2019 - 07:01 PM

I thought that maybe I needed to create an employee object. I don't think I'm using it in any of the code I posted.

This post has been edited by Skydiver: 02 October 2019 - 07:04 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#4 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 3001
  • View blog
  • Posts: 11,551
  • Joined: 03-December 12

Re: I'm trying to use the array

Posted 02 October 2019 - 07:03 PM

What do you think this does?

empArray[employeecounter] = new Employee();


Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7139
  • View blog
  • Posts: 24,248
  • Joined: 05-May 12

Re: I'm trying to use the array

Posted 02 October 2019 - 07:06 PM

makeitrain: There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area. If you must quote, trim it down to specifics that you want to address.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1