4. A program is required for a grocer that will add two weights together (in pounds and ounces). The program should also convert the total weight to a value in kilograms.
Use three functions.
Function 1: allows the user to enter the name of the produce, and the weights in pounds and ounces, which are validated and stored..
Function 2: calculates the total weight in pounds and ounces and converts that to kilograms.
Function 3: displays the name of the produce, the total weight in pounds and ounces and the total weight in kilograms.
Think about function 2 and the actual values that will be returned from this function.
The user should be given an option to convert another weight or end the program
Note: there are 16 ounces in one pound, and there are 0.454 kilograms in one pound.
here is what i have so far:
string product; Single weightp = 0f; Single weighto= 0f; Single convertp= 0f; Single ptokilo = 0.45359237f; Single converto= 0f; Single otokilo = 0.0283495231f; Single totalkiloweight = 0f; Console.WriteLine("the name of the produce"); product = Console.ReadLine(); Console.WriteLine("Enter weight in poounds"); weightp = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter weight in Ounces"); weighto = Convert.ToInt32(Console.ReadLine()); convertp = weightp * ptokilo; Console.WriteLine("Here is pounds converted to kilograms"); Console.WriteLine(convertp); converto = weighto * otokilo; Console.WriteLine("Here is Ounces converted to kilograms"); Console.WriteLine(converto); totalkiloweight = converto + convertp; Console.WriteLine("Here is the total Weight in Kilograms for the two weights"); Console.WriteLine(totalkiloweight); Console.ReadKey();
any idead how to add a loop iv tried a while loop shows so many errors when i try to add it