Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SoftUni {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter the amount of money Ivan Cho has: ");
- double money = Double.parseDouble(sc.nextLine());
- System.out.print("Enter the number of students: ");
- int students = Integer.parseInt(sc.nextLine());
- System.out.print("Enter the price of a single lightsabre: ");
- double lightSabrePrice = Double.parseDouble(sc.nextLine());
- System.out.print("Enter the price of a single robe: ");
- double robePrice = Double.parseDouble(sc.nextLine());
- System.out.print("Enter the price of a single belt: ");
- double beltPrice = Double.parseDouble(sc.nextLine());
- int freeBelts = students / 6;
- double moreLightSabers = Math.ceil(students * 0.1);
- double totalPrice = (students + (int) moreLightSabers) * lightSabrePrice
- + students * robePrice +
- (students-freeBelts) * beltPrice;
- if(money >= totalPrice){
- System.out.println("The money is enough - it will cost-" + totalPrice + " lv.");
- }
- else{
- System.out.printf("Ivan Cho will need %.2f lv. more.",(totalPrice-money));
- }
- }
- }
Add Comment
Please, Sign In to add comment