Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CatFood {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int cats = Integer.parseInt(scanner.nextLine());
- int groupOne = 0;
- int groupTwo = 0;
- int groupThree = 0;
- double totalFood = 0;
- for (int i = 1; i <= cats; i++) {
- double food = Double.parseDouble(scanner.nextLine());;
- totalFood += food;
- if (food >= 100 && food < 200)
- {
- groupOne++;
- }
- else if (food >= 200 && food < 300)
- {
- groupTwo++;
- }
- else if (food >= 300 && food < 400)
- {
- groupThree++;
- }
- }
- double total = 0.0;
- System.out.printf("Group 1: %d cats.%n", groupOne);
- System.out.printf("Group 2: %d cats.%n" , groupTwo);
- System.out.printf("Group 3: %d cats.%n", groupThree);
- total = (totalFood / 1000) * 12.45;
- System.out.printf("Price for food per day: %.2f lv.", total);
- }
- }
Add Comment
Please, Sign In to add comment