Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ExDaySix07;
- import java.util.Scanner;
- public class Fish {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int fishing = Integer.parseInt(scan.nextLine());
- String fish = scan.nextLine();
- int fishCount = 0;
- double money = 0.0;
- double budget = 0.0;
- boolean end = false;
- while (!"Stop".equals(fish)) {
- double kg = Double.parseDouble(scan.nextLine());
- fishCount++;
- int asciiSum = 0;
- asciiSum = 0;
- for (int i = 0; i < fish.length(); i++) {
- asciiSum += fish.charAt(i);
- money = asciiSum * 1.0 / kg;
- }
- if (fishCount % 3 == 0) {
- budget += money;
- } else {
- budget -= money;
- }
- if (fishCount == fishing) {
- System.out.println("Lyubo fulfilled the quota!");
- break;
- }
- fish = scan.nextLine();
- }
- if (budget >= 0) {
- System.out.printf("Lyubo's profit from %d fishes is %.2f leva.", fishCount, budget);
- } else if (budget < 0) {
- System.out.printf("Lyubo lost %.2f leva today.", Math.abs(budget));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment