我如何......如何从数字中减去一个百分比 [英] How do i...how to subtract a percentage from a number

查看:281
本文介绍了我如何......如何从数字中减去一个百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是如果数字大于1000减去10%,如果不减去5%

请帮助我们在学校的项目

感谢那些会有所帮助。



我尝试了什么:



i没有尝试了任何代码,因为我不知道使用什么代码

the problem is " If number is greater than 1000 subtract 10% , if not subtract 5% "
Please Help its our Project in school
Thanks for those who will help .

What I have tried:

i didn't tried any codes yet cause i don't have any idea what code to use

推荐答案

嘿,首先你必须知道变量,语法,声明,初始化等基本原理,循环,if .... else格式等。

这是你的要求的逻辑。

if(num> 1000){

total = num-(num * 0.10)

} else {total = num - (num * 0.05}
Hey,first you have to know the fundamentals like variable,syntax,declaration,initialisation,loop,if....else format etc.
This is the logic of your requirement.
if(num > 1000) {
total = num-(num*0.10)
} else { total = num - (num*0.05}


Quote:

我如何...如何从数字中减去百分比

How do i...how to subtract a percentage from a number



作为程序员,你需要放心数学。百分比是小学水平。


As a programmer, you need to be at ease with mathematics. percentages is primary school level.

Quote:

减去10%一个数字



翻译成数字 - 数字的10%=> 数字 - (10/100)*数字

也可以被视为数字*(1 - 10/100)=> 数字* 0.9



我们不做你的家庭作业。

HomeWork不会在乞求别人做的时候测试你的技能你的工作,它会让你思考并帮助你的老师检查你对你所学课程的理解,以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

所以,试一试,重读你的课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。



作为程序员,您的工作是创建算法解决特定问题,你不能依赖别人永远为你做,所以有一段时间你必须学会​​如何。而且越快越好。

当你要求解决方案时,就像试图通过培训其他人来学习开车一样。

创建算法基本上是找到数学并进行必要的调整以适应你的实际问题。


translate to "number - 10% of number" => "number - (10 / 100) * number"
can also be seen as "number * (1 - 10 / 100 )" => "number * 0.9"

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.


你好:

将原始变量设为 x 并且你想得到的结果是变量结果,那么你可以使用:

result = x *(x> 1000?0.9?0.95)



说明:

表达式(x> 1000?0.9?0.95)具有以下价值:

   - 0.9 仅当x> 1000

   - 0.95 否则



因此,结果具有以下值:

   - x减去x的10%仅当x> 1000

   - x减去x的5%否则
Hello:
Supose your original variable is x and the result that you want to get is the variable result, then you can use:
result=x*(x>1000?0.9?0.95)

Explanation:
The expresion (x>1000?0.9?0.95) has the following value:
  - 0.9 only if x>1000
  - 0.95 otherwise

So, result has teh following value:
  - x less a 10% of x only if x>1000
  - x less a 5% of x otherwise


这篇关于我如何......如何从数字中减去一个百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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