Advertisement
Valantina

SummerShopping/Ex27.07.2019

Jul 29th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P02_SummerShopping
  4. {
  5.     class P02_SummerShopping
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int budget = int.Parse(Console.ReadLine());
  10.             double towelPrice = double.Parse(Console.ReadLine());
  11.             int discountPercent = int.Parse(Console.ReadLine());
  12.  
  13.             double umbrellaPrice = (towelPrice * 2) / 3;
  14.             double flipFlopPrice = umbrellaPrice * 0.75;
  15.             double bagPrice = (flipFlopPrice + towelPrice) / 3;
  16.  
  17.             double finalPrice = (towelPrice + umbrellaPrice + flipFlopPrice + bagPrice) * (1 - discountPercent / 100.0);
  18.             double difference = Math.Abs(finalPrice - budget);
  19.  
  20.             if (finalPrice <= budget)
  21.             {
  22.                 Console.WriteLine($"Annie's sum is {finalPrice:F2} lv. She has {difference:F2} lv. left.");
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine($"Annie's sum is {finalPrice:F2} lv. She needs {difference:F2} lv. more.");
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement