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 dailyQuota = Integer.parseInt(scanner.nextLine());
- String fishName = scanner.nextLine();
- int fishCount = 0;
- double profit = 0;
- double lostMoney = 0;
- double fishKg = 0;
- while (!fishName.equals("Stop")) {
- fishKg = Double.parseDouble(scanner.nextLine());
- int fishNameLength = fishName.length();
- fishCount++;
- int fishNameSum = 0;
- double price = 0;
- for (int pos = 0; pos < fishNameLength; pos++) {
- char currentSymbol = fishName.charAt(pos);
- int asciiValue = (int) currentSymbol;
- fishNameSum += asciiValue;
- price = fishNameSum / fishKg;
- if (fishCount % 3 == 0) {
- profit += price;
- } else {
- profit -= price;
- }
- }
- if (fishCount == dailyQuota) {
- System.out.println("Lyubo fulfilled the quota!");
- break;
- }
- fishName = scanner.nextLine();
- }
- if (profit >= 0) {
- System.out.printf("Lyubo's profit from %d fishes is %.2f leva.", fishCount, profit);
- } else {
- System.out.printf("Lyubo lost %.2f leva today.", profit);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement