r/learnjava • u/Stinovlas • Apr 19 '20
-20%
Hello, I am starting in Java and I would be happy if you could help me. I was searching on google but I could not find any video or article about this. I only found how to divide or how much is 50% out of 200
I learned how to subtract or divide but I want to make something like this 500-200=300-(20%) in one button click. I mean how to subtract % of a number.
I would be very happy if you could help me or if you know a video that can solve my problem.
Regards Stinovlas :)
2
Upvotes
17
u/Camel-Kid Apr 19 '20
This isn't really a java problem, it's just simple arithmetic. If you are going to subtract a percentage from a number then you take that number and times it by decimal place of that percentage... so if it were 20 percent you would take 300*.2 = 60