Advertisement
A4L

Chapter - 07 - User Input

A4L
Dec 7th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TryOut1_CylindersCompleteProgram
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Player's Guide to C#\nTry Out 01 - Chapter 7 'User Input' \n\nThis code will not check for errors and only accept numbers.");
  14.             Console.WriteLine("Please input the Base Radius of a Cylinder");
  15.                 string userInput = Console.ReadLine();
  16.                 float numBaseRad = Convert.ToSingle(userInput);
  17.                 Console.WriteLine("Radius of the Base : " + numBaseRad);
  18.             Console.WriteLine("\nPlease input the Height of a Cylinder");
  19.                 userInput = Console.ReadLine();
  20.                 float numHeight = Convert.ToSingle(userInput);
  21.                 Console.WriteLine("Height : " + numHeight);
  22.  
  23.                 float pi = 3.1415926f;
  24.                 float outRadius = pi * numBaseRad * numBaseRad * numHeight;
  25.             Console.WriteLine($"\nThe Volume of the Cylinder is : {outRadius}");
  26.                 float outSurfaceA = 2 * pi * numBaseRad*(numBaseRad + numHeight);
  27.             Console.WriteLine($"The Surface area of the Cylinder is : {outSurfaceA}");
  28.  
  29.  
  30.  
  31.             Console.ReadKey();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement