C# programming. In countries using the metric system, many products are sold by
ID: 3882805 • Letter: C
Question
C# programming. In countries using the metric system, many products are sold by grams and kilograms are opposed to pounds and ounces. Write an application that converts grams to pounds and will display the price of the product by pound. Test your application by doing a compile-time initialization of Poutine a common Canadian dish, made with French fries, which sells for $ 1.29 per 100 grams. Display both the metric and customary U.S. Units. Be sure to provide labels for all values. Once you get that portion running, go into your source code and rerun the application using additional items, such as haricot verts, which are a type of green beans sold at 0.75 per 100 grams. C# programming. In countries using the metric system, many products are sold by grams and kilograms are opposed to pounds and ounces. Write an application that converts grams to pounds and will display the price of the product by pound. Test your application by doing a compile-time initialization of Poutine a common Canadian dish, made with French fries, which sells for $ 1.29 per 100 grams. Display both the metric and customary U.S. Units. Be sure to provide labels for all values. Once you get that portion running, go into your source code and rerun the application using additional items, such as haricot verts, which are a type of green beans sold at 0.75 per 100 grams. C# programming.Explanation / Answer
Test 1:
C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
double price_per100gram = 1.29;
//note that 1gram = 0.00220462 pound so 100grams = 0.220462 pound
//so price for 0.220462 pound = price_per100gram = 1.29
double price_perpound = price_per100gram/0.220462;
Console.WriteLine("If Price per 100gram = {0}$ then price per pound = {1}$",(price_per100gram).ToString(),(price_perpound).ToString());
}
}
}
Sample Output:
Test 2:
C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
double price_per100gram = 0.75;
//note that 1gram = 0.00220462 pound so 100grams = 0.220462 pound
//so price for 0.220462 pound = price_per100gram = 0.75
double price_perpound = price_per100gram/0.220462;
Console.WriteLine("If Price per 100gram = {0}$ then price per pound = {1}$",(price_per100gram).ToString(),(price_perpound).ToString());
}
}
}
Sample Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.