Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Group2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double neededExperience = scanner.nextDouble();
- int countOfBattles = scanner.nextInt();
- double myExperience = 0.0;
- int num = 0;
- for (int i = 1; i <= countOfBattles; i++) {
- if(myExperience>=neededExperience){
- System.out.printf("Player successfully collected his needed experience for %d battles.",num );
- return;
- }
- int command = scanner.nextInt();
- if (i%3 != 0 && i%5 != 0 ) {
- myExperience +=command;
- num++;
- }
- if(i%3 ==0) {
- myExperience += (command + 0.15 * command);
- num++;
- }
- if(i%5==0){
- myExperience += (command - 0.10*command);
- num++;
- }
- }
- if(myExperience<neededExperience){
- double result = neededExperience-myExperience;
- System.out.printf("Player was not able to collect the needed experience, %.2f more needed.", result);
- }
- else {
- System.out.printf("Player successfully collected his needed experience for %d battles.",num );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement