You are here:

C/Help with pseudocode question

Advertisement


Question
need help with the following question in pseudocode:

Design a program that uses the following parallel arrays:

   empid: an array of seven integers to hold employee identification numbers. The array should be initialized with the following numbers:
   56888 45201, 78951 87775 84512 13028 75804
   hours: an array of seven integers to hold the number of hours worked by each employee
   payRate: an array of seven Real numbers to hold each employee's hourly pay rate
   wages: an array of seven Real numbers to hold employee's gross wages

The program should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the number of hours worked by the employee whose identification number is stored in element 0 of the empid array. That same employee's pay rate should be stored in the element 0 of the payRate array.

The program should display each employee number and ask the user to enter that employee's hours and pay rate. It should then calculate the gross wages for that employee (hours times pay rate), which should be stored in the wages array. After the data has been entered for all employees, the program should display each employee's indentification number and gross wages.

Answer
Hello Juan.

I see your assignment, but I don't see your question. What is it about your assignment that you are having trouble with?

I'll start you off with my version of pseudo code, and you can either finish it, or ask me a specific question. Everyone has their own style of pseudo code, there is no wrong way, as long as the code is detailed enough to convert into real code easily.

First, the assignment says there are some arrays. Let's "declare" them.

empid is an array of 7 integers = 56888 45201 78951 87775 84512 13028 75804
hours is an array of 7 integers
payRate is an array of 7 integers
wages is an array of 7 integers

Next, you need a loop to go over each empid and get the required information. Lets assume array indexes start at 0

for i from 0 through 6
do
  print empid[i]
  print "enter hours"
  read hours into hours[i]
  print "enter pay rate"
... you do the rest ...
done

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.