Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Pets {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int NumberOfDays = Integer.parseInt(scanner.nextLine());
- int LeftFood = Integer.parseInt(scanner.nextLine());
- double FoodForDogkg = Double.parseDouble(scanner.nextLine());
- double FoodForCatkg = Double.parseDouble(scanner.nextLine());
- double FoodForTurtleGr = Double.parseDouble(scanner.nextLine());
- double neededfoodfordog = NumberOfDays * FoodForDogkg;
- double neededfoodforcat = NumberOfDays * FoodForCatkg;
- double neededfoodforturtle = NumberOfDays * (FoodForTurtleGr / 1000);
- double Totalamountoffood = neededfoodfordog + neededfoodforcat + neededfoodforturtle;
- if (LeftFood > Totalamountoffood)
- { double RemainFood = LeftFood - Totalamountoffood;
- System.out.printf( "%.0f kilos of food left" , Math.floor(RemainFood)); }
- else
- {double NeededFood = Totalamountoffood - LeftFood;
- System.out.printf( "%.0f more kilos of food are needed." , Math.ceil(NeededFood)) ;}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement