Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Fishing {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int fishes = Integer.parseInt(scanner.nextLine());
- double income = 0;
- double outcome = 0;
- boolean fullFilth = false;
- int fishCount = 0;
- for (int i = 1; i <= fishes; i++) {
- String name = scanner.nextLine();
- if ("Stop".equals(name)) {
- fullFilth = true;
- break;
- }
- double kg = Double.parseDouble(scanner.nextLine());
- int currentFishPrice = 0;
- for (int j = 0; j < name.length(); j++) {
- int value = name.charAt(j);
- currentFishPrice += value;
- }
- fishCount++;
- double price = currentFishPrice * 1.00 / kg;
- if (fishCount % 3 == 0) {
- income += price;
- } else {
- outcome += price;
- }
- }
- if (!fullFilth) {
- System.out.println("Lyubo fulfilled the quota!");
- }
- if (income >= outcome) {
- System.out.printf("Lyubo's profit from %d fishes is %.2f leva.", fishCount, income - outcome);
- } else {
- System.out.printf("Lyubo lost %.2f leva today.", Math.abs(income - outcome));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement