Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package SamiqtIzpit;
- import java.util.Scanner;
- public class P04 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- double finalsales = 0;
- double ratingcount = 0;
- for (int i = 1; i <n ; i++) {
- double rating = 0;
- int num = Integer.parseInt(scanner.nextLine());
- if (num % 10 == 2){
- rating = 0;
- ratingcount +=2;
- } else if (num % 10 == 3) {
- rating = 0.5;
- ratingcount +=3;
- } else if (num % 10 == 4) {
- rating = 0.7;
- ratingcount +=4;
- } else if (num % 10 == 5) {
- rating = 0.85;
- ratingcount +=5;
- }else {
- rating=1.0;
- ratingcount +=6;
- }
- String firsttwodec = "";
- String numSrt = Integer.toString(num);
- for (int j = 0; j <=1 ; j++) {
- char r =numSrt.charAt(j);
- String newstr = r + "";
- firsttwodec = firsttwodec + newstr;
- }
- int decimal = Integer.parseInt(firsttwodec);
- double sales = decimal + rating;
- finalsales += sales;
- }
- System.out.printf("%.2f\n", finalsales);
- System.out.printf("%.2f", ratingcount /n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement