i am using visual basic console application to create programs and here is the question.
- 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.
[/CODE]
HERE ISTHE WHAT I HAVE DONE SO FAR IS THIS RIGHT
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();
i have feeling the question does not sya o convert the pound and oucnes to kilograms but i think it means to say it convert pounds to oucnes then convert this answer to kilograms which is correct??
please help..