In this tutorial we’ll learn How to convert grams to pounds with ounces
Firstly we should know the converting grams to pounds formule
1 gram (g) is equal to 0.00220462262185 pounds (lbs)
1 g = 0.00220462262185 lb
After converting grams to pounds, we should convert the decimal part to ounces
1 pound (lb) is equal to 16 ounces (oz):
1 lb = 16 oz
Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
class Program { static void Main(string[] args) { Console.WriteLine("Converting grams to lbs in C# \n"); Console.Write("Enter a number in Grams: "); double grams = Convert.ToDouble(Console.ReadLine()); double pounds = grams * 0.00220462262185; double ounces = pounds - Math.Floor(pounds); pounds -= ounces; ounces *= 16; Console.WriteLine("{0} grams is {1} lbs and {2} oz.", grams, pounds, ounces); Console.ReadLine(); } } |
Output: