galinyotsev123

ProgBasicsExam1and2December2018-E05projectPrize

Dec 29th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E05projectPrize {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int projectPieces = Integer.parseInt(scanner.nextLine());
  8.  
  9. double moneyPrizePerPiece = Double.parseDouble(scanner.nextLine());
  10.  
  11. double sum = 0;
  12. int counter = 0;
  13. for (int i = 0; i < projectPieces; i++) {
  14. double pointsPerPiece = Double.parseDouble(scanner.nextLine());
  15. counter++;
  16.  
  17. if(counter % 2 == 0 ){
  18.  
  19. sum+=pointsPerPiece * 2;
  20. }
  21. else{
  22. sum+=pointsPerPiece;
  23. }
  24.  
  25. }
  26. double totalPrize =sum*moneyPrizePerPiece;
  27.  
  28. System.out.printf("The project prize was %.2f lv.", totalPrize);
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment