MartinPaunov

Metric-Converter

Apr 17th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 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 CSharpDemo
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {          
  13.             // Read the input
  14.             double inputCount = double.Parse(Console.ReadLine());
  15.             string fromMetric = Console.ReadLine();
  16.             string toMetric = Console.ReadLine();
  17.                
  18.             //Declare two additional variables to store current calculations
  19.             double middleValue = 0;   // -> Store middle value here
  20.             double totalValue = 0;    // -> Store total value here
  21.  
  22.             // Calculate middleValue
  23.  
  24.             if (fromMetric == "mm")
  25.             {
  26.                 middleValue = inputCount / 1000;
  27.             }
  28.             //TO DO -> Calculate all the possible cases of input metric so you can always store the correct middle value
  29.             //
  30.             //
  31.  
  32.  
  33.             //Check and calculate middle to total Value
  34.  
  35.             if (toMetric == "mm")
  36.             {
  37.                 totalValue = middleValue * 1000;
  38.             }
  39.             //TO DO  -> calculate the total value for all the possible output metrics
  40.  
  41.             Console.WriteLine($"{totalValue:f8}");    //-> Print the result
  42.  
  43.             //In order to solve the problem you have to complete all "TO DO" cases -> use if() and else if() conditional statements
  44.            
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment