Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C# Kilograms to stone and more converter.

  • Thread starter Deleted member 613
  • Start date
D

Deleted member 613

Guest
C#:
using System;

class MainClass
{
  public static void Main (string[] args)
  {
      //Changes the text colour.
      Console.ForegroundColor = ConsoleColor.Blue;
      Console.WriteLine("C# Conversion Application...");
      Console.ForegroundColor = ConsoleColor.Red;
      Console.WriteLine("Warning: The answers you get are only approximate values. I recommend rouding the answer.");
      Console.ForegroundColor = ConsoleColor.Blue;
      Console.WriteLine("Press any key to continue.");
      Console.ReadLine();
      Console.Clear();
      Console.ForegroundColor = ConsoleColor.White;
      Console.WriteLine("Would you like to convert:");
      Console.WriteLine("Miles to kilometers - Option 1");
      Console.WriteLine("Kilometers to miles - Option 2");
      Console.WriteLine("Kilograms to stone - Option 3");
      Console.WriteLine("Stone to kilograms - Option 4");
      //Takes in the users input and stores it.
      int answer = int.Parse(Console.ReadLine());
      if(answer == 1)
      {
          Console.Clear();
          Console.WriteLine("You have chosen: miles to kilometers.");
          Console.WriteLine("Please state the number");
          int num1 = int.Parse(Console.ReadLine());
          //Takes the user's number, multiplies it, and then prints it.
          double multiplier = 1.60934;
          double num3 = num1 * multiplier;
          Console.Clear();
          Console.WriteLine("The answer is:");
          Console.WriteLine(num3);
      }
      else if(answer == 2)
      {
          Console.Clear();
          Console.WriteLine("You have chosen: kilometers to miles.");
          Console.WriteLine("Please state the number");
          int num1 = int.Parse(Console.ReadLine());
          //Takes the user's number, divides it, and then prints it.
          double multiplier = 1.60934;
          double num3 = num1 / multiplier;
          Console.Clear();
          Console.WriteLine("The answer is:");
          Console.WriteLine(num3);
      }
      else if (answer == 3)
      {
          Console.Clear();
          Console.WriteLine("You have chosen: kilograms to stone.");
          Console.WriteLine("Please state the number");
          int num1 = int.Parse(Console.ReadLine());
          //Takes the user's number, divides it, and then prints it.
          double multiplier = 6.35;
          double num3 = num1 / multiplier;
          Console.Clear();
          Console.WriteLine("The answer is:");
          Console.WriteLine(num3);
      }
      else if (answer == 4)
      {
          Console.Clear();
          Console.WriteLine("You have chosen: stone to kilograms.");
          Console.WriteLine("Please state the number");
          int num1 = int.Parse(Console.ReadLine());
          //Takes the user's number, multiplies it, and then prints it.
          double multiplier = 6.35;
          double num3 = num1 * multiplier;
          Console.Clear();
          Console.WriteLine("The answer is:");
          Console.WriteLine(num3);
      }
      else
      {
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("Fatal Error. Programm terminated");
      }
  }
}
:) Converts kg to stone and vice versa
Converts miles to km and vice versa
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom