need help with looping
DISCLAIMER: The teacher in my class DOES NOT provide any examples or show any examples in class for looping (and the one example he showed us he said it was wrong, he used wrong example), and in addition to that he did not say whether it is a control loop, nested loop, a for, do, or while loop, thus I am in need of assistance of help here as I have a EXTREMELY LAZY TEACHER.
I am only going to post a part of the thing I need help with (Part II of question LOOPING)
Edit: Posted full question for clarification.
The Wacky Widgets Welding Company wants to calculate the pay increase for each of its employees over the next ten years. The company currently plans to increase each employee’s pay by 5 percent each year. For example, an employee who currently earns $25,000 a year will earn $26,250 next year, $27,562.50 the second year, and $28,940.63 the third year. Design the following, creating two class diagrams and pseudocode:
a) An Employee service class that contains an employee id number and the employee’s current yearly salary. Include the following:
i) A default constructor and an overloaded constructor. ii) Accessor and mutator methods for each attribute.b) A PayReport application class that contains two methods: the main() method and the printPayData() method. The main() method reads Employee records from a file named "employee.txt" and sends them, one at a time, to the printPayData() method. The printPayData() method produces a report that shows employee's number and the salary of the employee for each of the next 10 years.
This is what I gathered so far from the assignment and help from the textbook.
Public class PayReport
Public void main ()
Employee oneWorker
Open (Employee.txt)
oneWorker = read (Employee.txt)
while oneWorker is not at end of file
printPayData = read(employee.txt)
endwhile
close(employee.txt)
return
public void printPayData (Employee emp)
integer gross
gross = emp.getemployeesalary() * 0.5
print emp.getemployeeid(), gross
return
endClass
So I was wondering am I doing the looping wrong, what are the flaws with the looping right now, and is there any flaws with the looping right now, and what are the changes needed for this looping.
Here is more information if anyone needs any elaboration or clarification of what I am basing my looping on off.
Employee service class
public class Employee
// declarations
private employeeid : integer
private employeesalary : integer
public开发者_如何转开发 Employee ()
employeeid = 0
employeesalary = 0
return
public Employee (id : integer, salary : integer)
employeeid = id
employeesalary = salary
return
public integer getemployeeid ( )
return employeeid
public integer getemployeesalary ( )
return employeesalary
public void setCustomeraget(integer id)
employeeid = id
return
public void setEmployeesalary (integer salary)
employeesalary = salary
return
End Class
so the employee.txt = would come from this class right here).
PS: if any additional information is needed, I will edit it and provide more information
MY question is, is the loop that I based of my pseudocode flawed, doesn't work, and are changes needed to the loop I created based of my pseudocode.
When I created a class diagram of this in ArgoUML and then tried to generate a code for it, the class is not listed there, it's blank.
EX.
generation code for project
Available Classes
blank (N/A)
I see a couple of problems with your code.
- printPayData = read(employee.txt)
This looks like your setting printPayData equal to what you read from the file, when you want to pass the info read to the function. This might be more appropriate.
printPayData( read(employee.txt) )
2. printPayData does not print out an employees salary over the next 10 years. It should look more like this.
print employeeNumber
integer i = 0
integer salary = current employee Salary
while ( i < 10 )
print salary
salary = salary * 1.05
i = i + 1
end while
精彩评论