Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package LoopsInLoops_exercise;
- import java.util.Scanner;
- public class FishingASCII {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int fish = Integer.parseInt(scanner.nextLine());
- String fishName ="";
- double fishWeigh = 0;
- int fishMoney = 0;
- double spens = 0;
- double moneyGet = 0;
- int count=1;
- boolean isReach = false;
- for (int i = 1; i <=fish ; i++) {
- fishName = scanner.nextLine();
- if(fishName.equals("Stop")) break;
- fishWeigh = Double.parseDouble(scanner.nextLine());
- for (int j = 0; j <fishName.length() ; j++) {
- fishMoney +=fishName.charAt(j);
- }
- if(count%10==3){
- moneyGet += fishMoney/fishWeigh;
- }else{
- spens += fishMoney/fishWeigh;
- }
- count++;
- fishMoney =0;
- }
- if(count-1 == fish){
- isReach=true;
- }
- if(isReach) {
- System.out.println("Lyubo fulfilled the quota!");
- }
- // int test=(int)(moneyGet*100);
- // moneyGet=test*1.0/100;
- // test=(int)(spens*100);
- // spens= test*1.0/100;
- if(moneyGet>spens){
- System.out.printf("Lyubo's profit from %d fishes is %.2f leva.",count-1,moneyGet-spens);
- }else if(spens>moneyGet){
- System.out.printf("Lyubo lost %.2f leva today.",spens-moneyGet);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement