Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class ComputerSales
- {
- public static void Main(string[] args)
- {
- Console.WriteLine("Enter the number of computer models: ");
- int numModels = int.Parse(Console.ReadLine());
- int totalSales = 0;
- int totalRatings = 0;
- for (int i = 0; i < numModels; i++)
- {
- Console.WriteLine("Enter sales and rating for model {0}: ", i + 1);
- int salesAndRating = int.Parse(Console.ReadLine());
- int sales = salesAndRating / 100; // possible sales
- int rating = salesAndRating % 10; // rating
- int calculatedSales;
- switch (rating)
- {
- case 2:
- calculatedSales = 0;
- break;
- case 3:
- calculatedSales = (int)(sales * 0.5);
- break;
- case 4:
- calculatedSales = (int)(sales * 0.7);
- break;
- case 5:
- calculatedSales = (int)(sales * 0.85);
- break;
- case 6:
- calculatedSales = sales;
- break;
- default:
- calculatedSales = 0;
- break;
- }
- totalSales += calculatedSales;
- totalRatings += rating;
- }
- double averageRating = (double)totalRatings / numModels;
- double averageSales = (double)totalSales / numModels;
- Console.WriteLine("Average rating: {0}", averageRating);
- Console.WriteLine("Average sales: {0}", averageSales);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement