Advertisement
alexpeevk9

5.Split Temporary Variable - Refactored Code

Dec 28th, 2021
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. namespace FifthExampleRefactored
  2. {
  3.     using System;
  4.     class Program
  5.     {
  6.         private const double GRAVITY_EARTH = 9.18;
  7.         private const double GRAVITY_MARS = 3.72;
  8.         private const double GRAVITY_MOON = 1.62;
  9.         static void Main()
  10.         {
  11.             Console.Write("Enter your mass: ");
  12.             int mass = int.Parse(Console.ReadLine());
  13.             double earthWeight = GRAVITY_EARTH * mass;
  14.             Console.WriteLine($"Weight on earth: {earthWeight}");
  15.             double marsWeight = GRAVITY_MARS * mass;
  16.             Console.WriteLine($"Weight on Mars: {marsWeight}");
  17.             double moonWeight = GRAVITY_MOON * mass;
  18.             Console.WriteLine($"Weight on moon: {moonWeight}");
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement