2010-11-06 188 views
1

免责声明:我班的老师不提供任何示例或在课堂上显示循环的任何示例(以及他向我们展示的一个示例,他说这是错误的,他使用了错误的示例),并且此外因为他没有说它是一个控制循环,嵌套循环,for,do还是while循环,因此我需要这里的帮助,因为我有一个EXTREMALY LAZY TEACHER。需要帮助循环

我只是要发布的我需要(问题循环的第二部分)

编辑帮助的事情的一部分:澄清发布完整的问题。

Wacky Widgets Welding Company希望计算未来十年内每位员工的工资增长情况。该公司目前计划每年将每位员工的工资增加5%。例如,目前每年挣25,000美元的员工明年将获得26,250美元,第二年为27,562.50美元,第三年为28,940.63美元。设计以下内容,创建两个类图和伪代码:

a)包含员工ID号和员工当前年薪的员工服务类。包括以下内容:
  i)默认构造函数和重载构造函数。 ii)每个属性的访问器和增变器方法。 b)包含两种方法的PayReport应用程序类:main()方法和printPayData()方法。 main()方法从名为“employee.txt”的文件读取Employee记录,并一次一个地将它们发送到printPayData()方法。 printPayData()方法会生成一个报告,显示未来10年每个员工的员工数量和员工工资。

这是我从教科书中的任务和帮助迄今为止收集到的。

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 

所以我想知道我做错了循环错,什么是正确的与现在的循环缺陷,并在那里与现在的循环,什么任何瑕疵都需要这个循环的变化。

这里有更多的信息,如果任何人需要任何阐述或澄清我的基础我的循环关闭。

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 

所以employee.txt =会来自这里的这个类)。

PS:如果需要任何额外的信息,我会编辑,并提供更多的信息

我的问题是,是,我根据我的伪代码有缺陷的循环,不能正常工作,并且需要改变我根据我的伪代码创建的循环。

当我在ArgoUML中创建了这个类的类图,然后尝试为它生成一个代码时,该类没有在那里列出,它是空白的。

EX。项目

代码

可选职业

空(N/A)

+0

嗨,欢迎来到Stack Overflow。小费,你应该缩进4个空格的所有代码,这将正确格式化。正如你现在所看到的,只有你的类和类似的内容看起来像代码,因为这些部分是缩进的。祝你好运:) – 2010-11-06 21:07:43

+1

说实话,要了解你所问的究竟是什么,有点困难。根据你的伪代码判断,我会说,如果我正确地解释了与循环相关的代码,你就可以轻松一下。 – 2010-11-06 21:12:39

+0

请注意,这不是VB.NET代码:)您定位哪种编程语言? – 2010-11-09 12:28:38

回答

3

我看到一对夫妇的问题与您的代码。

  1. printPayData =读(employee.txt中)

这看起来像你的设置printPayData等于你从文件中读取的,当你想通过阅读给函数的信息。这可能更合适。

printPayData(读(employee.txt中))

2. printPayData不打印出雇员工资在未来的10年。它应该看起来更像这样。

print employeeNumber 
integer i = 0 
integer salary = current employee Salary 

while (i < 10) 
    print salary 
    salary = salary * 1.05 
    i = i + 1 
end while 
+0

对此有几个问题。这是suppossed在循环的printdata部分,并补充说明你的supposse如何把它放在一个实际的循环。 – james 2010-11-06 22:05:55

+0

我的意思是说你的循环应该看起来如何。 – james 2010-11-06 22:06:24

+0

我看到了,所以这将公共无效的printPayData(Employee emp) 然后是吗? – james 2010-11-06 22:08:31