Spocoman

07. Shopping

Nov 16th, 2021 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Shopping
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.  
  11.             int gpu = int.Parse(Console.ReadLine());
  12.             int cpu = int.Parse(Console.ReadLine());
  13.             int ram = int.Parse(Console.ReadLine());
  14.  
  15.             int gpuPrice = gpu * 250;
  16.             double cpuPrice = cpu * gpuPrice * 0.35;
  17.             double ramPrice = ram * gpuPrice * 0.10;
  18.                      
  19.             double totalAmount = gpuPrice + cpuPrice + ramPrice;
  20.  
  21.             if (gpu > cpu)
  22.             {
  23.                 totalAmount *= 0.85;
  24.             }
  25.             if (budget >= totalAmount)
  26.             {
  27.                 Console.WriteLine($"You have {(budget - totalAmount):f2} leva left!");
  28.             }
  29.             else
  30.             {
  31.                 Console.WriteLine($"Not enough money! You need {(totalAmount - budget):f2} leva more!");
  32.             }
  33.         }
  34.     }
  35. }
Add Comment
Please, Sign In to add comment