Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exam;
- import java.util.Scanner;
- public class Fourth {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int computers = Integer.parseInt(scanner.nextLine());
- double sales = 0;
- double avgPercent = 0;
- for(int i = 1 ; i <= computers; i++){
- int number = Integer.parseInt(scanner.nextLine());
- int lastDigit = number % 10;
- int remainingDigits = number / 10;
- double percents = 0;
- if(lastDigit == 2){
- percents = 0;
- }else if(lastDigit == 3){
- percents = 50;
- }else if(lastDigit == 4){
- percents = 70;
- }else if(lastDigit == 5){
- percents = 85;
- } else if (lastDigit == 6){
- percents = 100;
- }
- sales += remainingDigits * (percents / 100);
- avgPercent += lastDigit;
- }
- avgPercent = avgPercent / computers;
- System.out.printf("%.2f%n",sales);
- System.out.printf("%.2f",avgPercent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment