Advertisement
BbJLeB

Fishing

Nov 21st, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fishing(input) {
  2. let priceOfTheFish = 0.0;
  3. let fishCounter = 1;
  4. let testFinalPrice = 0.0;
  5. let difference = 0.0;
  6. let bonusPrice = 0.0;
  7. while (!"Stop"){
  8.     fishKilogrames = Number(input.shift());
  9.  
  10.     for ( i = fishName.length() - 1; i >= 0; i--) {
  11.         symbolSum = String.fromCharAt(fishName);
  12.         priceOfTheFish = symbolSum + priceOfTheFish;
  13.         testFinalPrice = priceOfTheFish / fishKilogrames;
  14.     }
  15.     if (fishCounter != 3){
  16.         difference = difference + testFinalPrice;
  17.     }else {
  18.         bonusPrice = bonusPrice + testFinalPrice;
  19.     }
  20.     priceOfTheFish = 0;
  21.     testFinalPrice = 0;
  22.  
  23.     fishCounter++;
  24.     if (fishCounter == catchedFish + 1){
  25.         console.log(`Lyubo fulfilled the quota!`);
  26.         break;
  27.     }
  28.     fishName = input.shift();
  29. }
  30. if (difference > bonusPrice){
  31.     realFinalPrice = difference - bonusPrice;
  32.     console.log(`Lyubo lost ${realFinalPrice.toFixed(2)} leva today. `);
  33. }else {
  34.    
  35.     console.log(`Lyubo's profit from ${fishCounter - 1} fishes is ${bonusPrice - difference} leva.`);
  36. }
  37. }
  38. fishing([ '3', 'catfish', '70', 'carp', '20', 'tench', '14' ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement