Advertisement
atanasovetr

Bonus

Mar 30th, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Bonus {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int number = scan.nextInt();
  7. int total = calculatingBonus(number);
  8. System.out.println(String.format("Your number without bonus: %d", number));
  9. System.out.println(String.format("Your number with bonus: %d", total));
  10. }
  11. public static int calculatingBonus(int number){
  12. int bonus = 0;
  13. int total = 0;
  14. if(number > 0) {
  15. if (number < 100) {
  16. bonus += 5;
  17. } else if (number < 1000) {
  18. bonus += number * 0.2;
  19. } else {
  20. bonus += number * 0.1;
  21. }
  22. }
  23. total = bonus + number;
  24. return total;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement