Advertisement
IvanITD

7. Shopping (Second Version)

Nov 29th, 2022 (edited)
1,128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | Source Code | 0 0
  1. using System;
  2.  
  3. namespace Shopping
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double peturBudget = double.Parse(Console.ReadLine());
  10.             int gpuAmount = int.Parse(Console.ReadLine());
  11.             int cpuAmount = int.Parse(Console.ReadLine());
  12.             int ramAmount = int.Parse(Console.ReadLine());
  13.  
  14.             double gpuPrice = gpuAmount * 250;
  15.             double cpuPrice = (gpuPrice * cpuAmount) * 0.35;
  16.             double ramPrice = (gpuPrice * ramAmount) * 0.10;
  17.  
  18.             double totalPrice = gpuPrice + cpuPrice + ramPrice;
  19.  
  20.             if (gpuAmount > cpuAmount)
  21.             {
  22.                 totalPrice -= totalPrice * 0.15;
  23.             }
  24.  
  25.             double remainingBudget = peturBudget - totalPrice;
  26.             double neededBudget = totalPrice - peturBudget;
  27.  
  28.             if (totalPrice <= peturBudget)
  29.             {
  30.                 Console.WriteLine($"You have {remainingBudget:F2} leva left!");
  31.             }
  32.             else if (totalPrice > peturBudget)
  33.             {
  34.                 Console.WriteLine($"Not enough money! You need {neededBudget:F2} leva more!");
  35.             }
  36.         }
  37.     }
  38. }
Tags: C#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement