Advertisement
Ivakis

Парична награда

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