Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exercise6;
- import java.util.Scanner;
- public class Fishing {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- String fish = scanner.nextLine();
- double profit = 0;
- int quota = 0;
- while (!"Stop".equals(fish)) {
- double weight = Double.parseDouble(scanner.nextLine());
- double nameInt = fish.length();
- double currentFishValue = 0;
- for (int i = 0; i < nameInt; i++) {
- char currentValue = fish.charAt(i); // Намираме стойността на една риба
- currentFishValue += currentValue;
- }
- quota++;
- if (quota != 3) {
- profit -= currentFishValue / weight;
- } else {
- profit += currentFishValue / weight;
- }
- if (quota >= n) {
- break;
- }
- fish = scanner.nextLine();
- }
- if (quota >= n) {
- System.out.println("Lyubo fulfilled the quota!");
- }
- if (profit > 0) {
- System.out.printf("Lyubo's profit from %d fishes is %.2f leva.", quota, profit);
- } else {
- System.out.printf("Lyubo lost %.2f leva today.", Math.abs(profit));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement