Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E08_Fishing {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int catchedFish = Integer.parseInt(scanner.nextLine());
- String fishName = scanner.nextLine();
- double priceOfTheFish = 0.0;
- int fishCounter = 1;
- double testFinalPrice = 0.0;
- double differnce = 0.0;
- double bonusPrice = 0.0;
- while (!"Stop".equals(fishName)){
- double fishKilogrames = Double.parseDouble(scanner.nextLine());
- for (int i = fishName.length() - 1; i >= 0; i--) {
- char symbolSum = fishName.charAt(i);
- priceOfTheFish = symbolSum + priceOfTheFish;
- testFinalPrice = priceOfTheFish / fishKilogrames;
- }
- if (fishCounter != 3){
- differnce = differnce + testFinalPrice;
- }else {
- bonusPrice = bonusPrice + testFinalPrice;
- }
- priceOfTheFish = 0;
- testFinalPrice = 0;
- fishCounter++;
- if (fishCounter == catchedFish + 1){
- System.out.println("Lyubo fulfilled the quota!");
- break;
- }
- fishName = scanner.nextLine();
- }
- if (differnce > bonusPrice){
- double realFinalPrice = differnce - bonusPrice;
- System.out.printf("Lyubo lost %.2f leva today.", realFinalPrice);
- }else {
- System.out.printf("Lyubo's profit from %d fishes is %.2f leva.", fishCounter - 1, bonusPrice - differnce);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement