Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E05projectPrize {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int projectPieces = Integer.parseInt(scanner.nextLine());
- double moneyPrizePerPiece = Double.parseDouble(scanner.nextLine());
- double sum = 0;
- int counter = 0;
- for (int i = 0; i < projectPieces; i++) {
- double pointsPerPiece = Double.parseDouble(scanner.nextLine());
- counter++;
- if(counter % 2 == 0 ){
- sum+=pointsPerPiece * 2;
- }
- else{
- sum+=pointsPerPiece;
- }
- }
- double totalPrize =sum*moneyPrizePerPiece;
- System.out.printf("The project prize was %.2f lv.", totalPrize);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment