打印出一张表格,显示每年年底各种整体的总余额 [英] Print out a table showing the total balances at the end of each year for various inte

查看:73
本文介绍了打印出一张表格,显示每年年底各种整体的总余额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们。我是新手,这是我后天上课的任务。因为我是新手,所以我制作了这个程序,但问题是答案必须采用这种形式:


初始存款? 10000

利率? 1.2

年数? 9

每年年底的余额:


开始结束

年度余额利息余额

1 10000.00 110.00 10110.00

2 10110.00 111.21 10221.21

3 10221.21 112.43 10333.64

4 10333.64 113.67 10447.31

5 10447.31 114.92 10562.23

6 10562.23 116.18 10678.42

7 10678.42 117.46 10795.88

8 10795.88 118.75 10914.64

9 10914.64 120.06 11034.70

10 11034.70 121.38 11156.08

但是由于我们没有涉及如何在表格中打印出来的主题,所以没有必要。我需要展示的是它每年如何添加并显示在年末余额。


这是我的代码:

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号

解决方案

你所要做的就是在你的do中输入你的变量。环。也许用空格分隔价值。


这会给你表格中的线条。


也许会变得更加惹人喜爱并且会对列标题进行cout就在你输入do之前循环。


我不知道。它不起作用。可以展示给我吗?是这样的吗?

展开 | 选择 | Wrap | 行号


否。以前是对的。 cin用于数据输入。你需要在do之前输入。循环。


这是你的行:


1 10000.00 110.00 10110.00


这是一个年,期初余额,利息和期末余额。


所以在循环中你:


do

{

cout余额。这是你的起始余额。


执行利息计算


cout兴趣


add平衡的利益。这是你的期末余额。


再次平衡余额。


}等等。


让这部分工作。然后重新发布,我们将处理年份和列标题。


顺便说一句:在你结束余额之前,你不要使用endl来保持同一条线/ BLOCKQUOTE>

Hey guys. I''m a newbie and this is my assignment for a class day after tomorrow. Since I''m new to this I made the program but the problem is the answer has to be in this form:

Initial deposit? 10000
Interest rate? 1.2
Number of years? 9
Balances at the end of each year:

Beginning Ending
Year Balance Interest Balance
1 10000.00 110.00 10110.00
2 10110.00 111.21 10221.21
3 10221.21 112.43 10333.64
4 10333.64 113.67 10447.31
5 10447.31 114.92 10562.23
6 10562.23 116.18 10678.42
7 10678.42 117.46 10795.88
8 10795.88 118.75 10914.64
9 10914.64 120.06 11034.70
10 11034.70 121.38 11156.08

But since we haven''t covered the topic on how to print it out in tables it''s not necessary. All I have to display is how it is added to each year and is shown at the year end balance.

Here''s my code:

Expand|Select|Wrap|Line Numbers

解决方案

All you have to do is cout your variables inside your "do" loop. Maybe separate the values with a space.

That will give you the lines in your table.

Maybe get fancier and cout the column titles just before you enter the "do" loop.


I don''t know. It''s not working. Could you show me? Is it like this?

Expand|Select|Wrap|Line Numbers


No. It was correct before. cin is for data input. You need the input before the "do" loop.

Here is your line:

1 10000.00 110.00 10110.00

It is a year , a beginning balance, interest, and the ending balance.

So in the loop you:

do
{
cout the balance. This s your starting balance.

perform the interest calculaton

cout the interest

add the interest to the balance. This is your ending balance.

cout the balance again.

}while etc.

Get this part working. Then post again and we''ll work on the year and the column titles.

BTW: You keep things on the same line by not using endl until after you cout the ending balance


这篇关于打印出一张表格,显示每年年底各种整体的总余额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆