Advertisement
Spocoman

Computer Firm

Sep 17th, 2023
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int modelCount, model, rating, sales;
  8.     cin >> modelCount;
  9.  
  10.     double totalSales = 0, totalRating = 0;
  11.  
  12.     for (int i = 0; i < modelCount; i++) {
  13.         cin >> model;
  14.  
  15.         rating = model % 10;
  16.         sales = model / 10;
  17.  
  18.         totalRating += rating;
  19.  
  20.         totalSales +=
  21.             (rating == 2 ? 0 :
  22.                 rating == 3 ? 0.5 :
  23.                 rating == 4 ? 0.7 :
  24.                 rating == 5 ? 0.85 : 1) * sales;
  25.     }
  26.  
  27.     printf("%.2f\n%.2f\n", totalSales, totalRating / modelCount);
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement