Advertisement
CoineTre

JF-ExcBasic09.Padawan Equipment

Jan 16th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Test {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double IvanMoney = Double.parseDouble(scanner.nextLine());
  7.         int students = Integer.parseInt(scanner.nextLine());
  8.         double lightsaberPrice = Double.parseDouble(scanner.nextLine());
  9.         double robesPrice = Double.parseDouble(scanner.nextLine());
  10.         double beltsPrice = Double.parseDouble(scanner.nextLine());
  11.         int freeBelts = students /6;
  12.         double sumMoney = lightsaberPrice*(Math.ceil(students * 1.1))+ robesPrice * students+ beltsPrice*(students-freeBelts);
  13.         double totalMoney = IvanMoney - sumMoney;
  14.         if (IvanMoney >= sumMoney){
  15.             System.out.printf("The money is enough - it would cost %.2flv.",sumMoney);
  16.         }else{
  17.             System.out.printf("Ivan Cho will need %.2flv more.",Math.abs(totalMoney));
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement