需要读取文件输入方面的帮助而不是计算!
我对我必须编写的这个程序感到非常困难。 该程序必须
从文件中读入
- 名称
- 要价
- 销售价格
- 仍欠抵押贷款的金额
打印并写入包含以下内容的表到文件中:
- 名称
- 要价
- 抵押金额
- 销售价格
- 房地产经纪人佣金
财产税净价< /p>
计算:
- 房地产经纪人佣金 = 售价 * 6%
- 房产税 = 售价 * 10.5%
- 净价 = 要价 - 抵押贷款金额 - 房地产经纪人佣金
- 总利润/损失 = 累计净值价格
我不知道如何分离数据并进行单独计算! 示例数据文件如下所示...
Hopkins 250000 223000 209000
Smith 305699 299999 297500
Forrest 124999 124999 53250
Fitch 214999 202500 200000
我无法读取数据然后进行计算,然后将新数据写入新文件,请帮忙!
I am have a real hard time with this program i have to write.
The program has to
Read in from the file
- Name
- Asking Price
- Sale Price
- Amount still owed on Mortgage
Print out AND write to a file a table that contains the following:
- Name
- Asking Price
- Mortgage Amount
- Selling Price
- Realtor Commission
Property Taxes Net price
Calculations:
- Realtor Commission = Selling Price * 6%
- Property Taxes = Selling Price * 10.5%
- Net Price = Asking Price - Mortgage Amount - Realtor Commission
- Total Profit / Loss = Accummulate the net prices
i have no clue how to separate the data and do separate calculations!!
A sample data file looks like this...
Hopkins 250000 223000 209000
Smith 305699 299999 297500
Forrest 124999 124999 53250
Fitch 214999 202500 200000
There is no way i can read the data then do the calculations and then write the new data to a new file, please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您使用的是 Java,因此在继续之前应该尝试为您的应用程序创建一个对象模型。解释整个方法很困难,但也许您可以从为应用程序创建类图开始。
我会尝试给出一些提示,但不会太具体。我想强调的是,以下只是其中一种方法,可能不是最好的方法。
从较高层面考虑您想要执行的操作以及这些操作将处理的数据。例如,在您的情况下,您有 3 项活动 - 从文件中读取、执行计算然后输出数据。为这些活动创建单独的工作人员类。还要考虑存储数据的类。这些类对于在工作类之间传递数据很有用。
接下来,设计类如何相互通信以完成工作。例如,您可以有一个控制器类,通过与其他组件协作来完成工作来管理 3 个活动。它可以调用文件读取器组件从文件中获取数据,然后将数据发送到计算组件进行计算并返回结果,然后将结果传递给写入器组件。
同样,这是一种简单的方法,但可能不是最好的解决方案。在进行过程中,根据需要进行审查和重构。
Since you are using Java, you should try to create an Object model for your application before proceeding. It is difficult to explain the entire approach but perhaps you could start with creating a class diagram for the application.
I'll try to give some hints without being too specific. I want to highlight that the following is just one of the ways to do it and may not be the best approach.
At a high level, think about the operations you want to perform and the data that the operations will work on. In your case, for ex, you have 3 activities - read from file, perform calculations and then output data. Create separate worker classes for these activities. Also think of classes that will store the data. These classes would be useful to pass along the data between worker classes.
Next, design how the classes will communicate with each other to get the job done. For ex, you could have a controller class that manages the 3 activities by collaborating with the other components to get the job done. It could call the file-reader component to get the data from the file, then it would send the data to calculating component to do the calculation and get back results which would then be passed to the writer-component.
Again, this is a simplistic approach but may not be the best solution. As you go along, review and refactor as necessary.