Advertisement
Valantina

Shopping/Exam

Jul 9th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P02_Shopping
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double peterBudget = double.Parse(Console.ReadLine());
  10.             int videoCardsCount = int.Parse(Console.ReadLine());
  11.             int processorsCount = int.Parse(Console.ReadLine());
  12.             int ramCount = int.Parse(Console.ReadLine());
  13.  
  14.             double totalPriceForVideoCards = videoCardsCount * 250;
  15.             double totalPriceForProcessors = processorsCount * (totalPriceForVideoCards * 0.35);
  16.             double totalPriceForRam = ramCount * (totalPriceForVideoCards * 0.1);
  17.  
  18.             double totalPrice = totalPriceForVideoCards + totalPriceForProcessors + totalPriceForRam;
  19.             double discount = 0;
  20.  
  21.             if (videoCardsCount > processorsCount)
  22.             {
  23.                 discount = totalPrice * 0.15;
  24.                 totalPrice -= discount;
  25.             }
  26.  
  27.             double moneyLeft = peterBudget - totalPrice;
  28.  
  29.             if (totalPrice <= peterBudget)
  30.             {
  31.                 Console.WriteLine($"You have {moneyLeft:F2} leva left!");
  32.             }
  33.             else
  34.             {
  35.                 moneyLeft = totalPrice - peterBudget;
  36.                 Console.WriteLine($"Not enough money! You need {moneyLeft:F2} leva more!");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement