Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class E01ExperienceGaining {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- double expNeeded = Double.parseDouble(sc.nextLine());
- double expTotal= 0;
- int battles = Integer.parseInt(sc.nextLine());
- for (int i = 1; i <= battles; i++) {
- double exp = Double.parseDouble(sc.nextLine());
- if (i % 3 == 0) {
- exp *= 1.15;
- }
- if (i % 5 == 0) {
- exp *= 0.9;
- }
- expTotal += exp;
- if (expTotal >= expNeeded) {
- System.out.printf("Player successfully collected his needed experience for %d battles.", i);
- return;
- }
- }
- System.out.printf("Player was not able to collect the needed experience, %.2f more needed.", expNeeded - expTotal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement