Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.nio.Buffer;
- public class P05AComputerFirm {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- int computersNumber = Integer.parseInt(reader.readLine());
- double rating = 0;
- double averageRating = 0;
- double possibleSales = 0;
- for (int i = 1; i <= computersNumber; i++) {
- double sales = Integer.parseInt(reader.readLine());
- if (sales % 10 == 2) {
- rating += 2;
- possibleSales += 0;
- } else if (sales % 10 == 3) {
- rating += 3;
- possibleSales += Math.floor(sales / 10 * 0.50);
- } else if (sales % 10 == 4) {
- rating += 4;
- possibleSales += Math.floor(sales / 10 * 0.70);
- } else if (sales % 10 == 5) {
- rating += 5;
- possibleSales += Math.floor(sales / 10 * 0.85);
- } else if (sales % 10 == 6) {
- rating += 6;
- possibleSales += Math.floor(sales / 10);
- }
- averageRating = rating / computersNumber;
- }
- System.out.printf("%.2f\n%.2f", possibleSales, averageRating);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment