03. Vacation
Здравейте, някой може ли да помогне?? Получавам само 55 точки, а когато напрява проба с примерите всичко си работи?!?!
Ето кода:
import java.util.Scanner; public class o77Task3 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double moneyForTrip = Integer.parseInt(scanner.nextLine()); double totalMoney = Integer.parseInt(scanner.nextLine()); int countDay = 0; int countSpendMoney = 0; while (totalMoney <= moneyForTrip && countSpendMoney < 5){ String doing = scanner.nextLine(); double sum = Double.parseDouble(scanner.nextLine()); countDay++; if (doing.equals("save")){ totalMoney += sum; countSpendMoney = 0; }else if (doing.equals("spend")){ totalMoney -= sum; countSpendMoney += 1; if (totalMoney < 0){ totalMoney = 0; } } if (countSpendMoney == 5){ System.out.println("You can't save the money."); System.out.println(countSpendMoney); break; } if (totalMoney >= moneyForTrip){ System.out.printf("You saved the money for %d days. ", countDay); break; } } } }