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