我如何使用C ++开始这个程序 [英] How I Can Do This Program Using C++ Am Beginner

查看:82
本文介绍了我如何使用C ++开始这个程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

5。计算一个人的净收入税。计算税收的规则是

•对第一个Rs不征税。 15,000的净收入。

•每卢比净收入超过卢比评估5%的税。 15,001卢比。 25,000。

•每卢比净收入超过卢比评估10%的税。 25,000



5. Calculate the tax on net income of a person. Rules for calculating tax are
• No tax is paid on first Rs. 15,000 of net income.
• A tax of 5% is assessed on each rupee of net income over Rs. 15,001 to Rs. 25,000.
• A tax of 10% is assessed on each rupee of net income over Rs. 25,000

#include<iostream>
using namespace std;
void main()
{
	int tax, income;
	cout << "please enter your income" << endl;
		if
			(income <= 15000)
			cout << "No Tax on you ! keep enjoying";
		else if
			(income <= 25000)
			tax = (income - 15000)*0.05;
		cout << "Tax=" << tax << endl;
		else
			(income > 25000)
			tax = (1000 * 0.05) + ((income-25000)*0.1);
		cout << "Tax=" << endl;
	system("pause"); 
}
</iostream>



我尝试但它在visual studio上出错


I try but it gives error on visual studio

推荐答案

我们不做你的作业:它是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!

(经OriginalGriff许可使用)




第一个错误:你的程序要求输入收入但从未读过键盘。

第二个错误: else 之后没有条件,只有在之后 c $ c>。

如果 {}
的使用情况>声明。
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
(Used with permission of OriginalGriff)


First mistake: Your program ask to type the income but never read the keyboard.
second mistake: there is no condition after else, only after if.
You should also read about the usage of {} with if statement.


你没有使用 {} 会给你错误:非法的其他没有



you are not using { and } that will give you error: illegal else without if

#include<iostream>
using namespace std;
void main()
{
	    int  income;
        float tax;          // make float variable, value may be in decimal points
	    cout << "please enter your income" << endl;
		if(income <= 15000)
        {                               //open {
		    cout << "No Tax on you ! keep enjoying";
        }                               //Close }
		else if(income <= 25000)
        {                               //open {
		    tax = (income - 15000)*0.05;
		    cout << "Tax=" << tax << endl;
        }                               //Close }
		else if(income > 25000) // or you can keep only 'else' without any condition
        {                               //open {
		    tax = (10000 * 0.05) + ((income-25000)*0.1);
		    cout << "Tax=" << endl;
        }                               //Close }
	system("pause"); 
}
</iostream>


这篇关于我如何使用C ++开始这个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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