Write a program that converts pounds into kilograms. The program prompts the user to enter a number in pounds, converts it to kilograms, and displays the result. One pound is 0.454 kilograms. Here is a sample run:
using System;
using System.Collections.Generic;
using System.Globalization;
namespace App
{
class Program
{
static void Main(string[] args)
{
const double KILOGRAMS_PER_POUND = 0.454; // Create constant value
// Prompt user to enter the number of pounds
Console.Write("Enter a number in pounds: ");
double pounds = double.Parse(Console.ReadLine());
// Convert pounds into kilograms
double kilograms = pounds * KILOGRAMS_PER_POUND;
// Display the results
Console.WriteLine(pounds.ToString() + " pounds is " + kilograms.ToString() + " kilograms");
Console.ReadLine();
}
}
}
Comments
Leave a comment