Advertisement
silvana1303

giftbox coverage

Jun 16th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double a = double.Parse(Console.ReadLine());
  14.             double sheets = double.Parse(Console.ReadLine());
  15.             double sheetArea = double.Parse(Console.ReadLine());
  16.             double allSheatArea = 0;
  17.  
  18.             double boxArea = a * a * 6;
  19.  
  20.                 for (int i = 1; i <= sheets; i++)
  21.                 {
  22.                     if (i % 3 == 0)
  23.                     {
  24.                         allSheatArea += sheetArea * 0.25;
  25.                     }
  26.                     else
  27.                     {
  28.                         allSheatArea += sheetArea;
  29.                     }
  30.                 }
  31.  
  32.             double percentage = allSheatArea / boxArea * 100.0;
  33.  
  34.             Console.WriteLine($"You can cover {percentage:f2}% of the box.");
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement