Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. package LoopsInLoops_exercise;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FishingASCII {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int fish = Integer.parseInt(scanner.nextLine());
  10.         String fishName ="";
  11.         double fishWeigh = 0;
  12.         int fishMoney = 0;
  13.         double spens = 0;
  14.         double moneyGet = 0;
  15.         int count=1;
  16.  
  17.         boolean isReach = false;
  18.  
  19.         for (int i = 1; i <=fish ; i++) {
  20.  
  21.             fishName = scanner.nextLine();
  22.             if(fishName.equals("Stop")) break;
  23.             fishWeigh = Double.parseDouble(scanner.nextLine());
  24.  
  25.             for (int j = 0; j <fishName.length() ; j++) {
  26.  
  27.                 fishMoney +=fishName.charAt(j);
  28.  
  29.             }
  30.             if(count%10==3){
  31.                 moneyGet += fishMoney/fishWeigh;
  32.             }else{
  33.                 spens +=  fishMoney/fishWeigh;
  34.             }
  35.             count++;
  36.             fishMoney =0;
  37.  
  38.  
  39.         }
  40.         if(count-1 == fish){
  41.             isReach=true;
  42.         }
  43.  
  44.         if(isReach) {
  45.             System.out.println("Lyubo fulfilled the quota!");
  46.         }
  47. //            int test=(int)(moneyGet*100);
  48. //               moneyGet=test*1.0/100;
  49. //               test=(int)(spens*100);
  50. //               spens= test*1.0/100;
  51.  
  52.             if(moneyGet>spens){
  53.  
  54.                 System.out.printf("Lyubo's profit from %d fishes is %.2f leva.",count-1,moneyGet-spens);
  55.             }else if(spens>moneyGet){
  56.                 System.out.printf("Lyubo lost %.2f leva today.",spens-moneyGet);
  57.             }
  58.            }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement