Guest User

Untitled

a guest
Dec 10th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. /**************************************************************/
  2. /* */
  3. /* Class: CIS 110 -- Programming I */
  4. /* */
  5. /* Program: Ch3Prb2.CS */
  6. /* */
  7. /* Programmer: Kyle Collins */
  8. /* */
  9. /* Purpose: This program, given the radius and the */
  10. /* height of a cylinder, will calculate the */
  11. /* surface area, and volume, of said cylinder */
  12. /* */
  13. /**************************************************************/
  14.  
  15. using System;
  16. using LibUtil;
  17.  
  18. // Begin namespace Ch3Prb2
  19. namespace Ch3Prb2
  20. {
  21. // Begin application class Ch3Prb2App
  22. class Ch3Prb2
  23. {
  24. static double radius, height, surfaceArea, volume;
  25.  
  26. static void Main()
  27. {
  28. ConsoleApp.ClrScr(); IdentifyApplication();
  29. InputRadius(); InputHeight();
  30. CalcSurfAndVol(); DisplayResults();
  31. }
  32.  
  33. static void IdentifyApplication()
  34. {
  35. Console.WriteLine("\nApplication: Ch3Prb2 -- Calculate the " +
  36. "surface area and volume of a cylinder\n");
  37. }
  38.  
  39. static void InputRadius()
  40. {
  41. Console.Write("Radius "); radius = Double.Parse(Console.ReadLine());
  42. }
  43.  
  44. static void InputHeight()
  45. {
  46. Console.Write("Height "); height = Double.Parse(Console.ReadLine());
  47. }
  48.  
  49. static void CalcSurfAndVol()
  50. {
  51. surfaceArea = 2 * Math.PI*(radius + height);
  52. volume = Math.PI * radius * 2 * height;
  53. }
  54.  
  55. static void DisplayResults()
  56. {
  57. Console.WriteLine();
  58. Console.WriteLine("Surface Area: {0}", surfaceArea);
  59. Console.WriteLine();
  60. Console.WriteLine("Volume: {0}", volume);
  61. Console.WriteLine();
  62. ConsoleApp.Pause();
  63. }
  64. } // End application class Ch3Prb2App
  65. } // End namespace Ch3Prb2
Add Comment
Please, Sign In to add comment