C# Convert measurements for grams to ounce

Write a program to allow a user to do conversions between two different units of measurement in C# They have to be converted Grams to Ounce.

Is this your homework assignment?

@The OP: It's clear that you just pasted a homework assignment directly into your post. Aside from the fact that this isn't a general programming forum, asking random people online to do your homework is unlikely to benefit you (IMHO). How is it going to help exactly? If you don't do this assignment, how will you be in a better position to do the next one? On a more positive note though, there are plenty of people who will be happy to help you with your homework, if you post to an appropriate forum and ask a specific question :)

2 Answers

2

I'm not going to write a whole program for you and i doubt any one will

however to get grams to ounces you times by 0.0352739619 and to get ounces to grams you divide by 0.0352739619

http://giyf.com or http://lmgtfy.com/?q=1+gram+in+ounces -.-

Thanks, it works!

That sounds a tad like a homework assignment to me, so I won't downright write it for you. ;) First of all, you need an input box (use Unity's GUI for that) and a conversion function, which takes a value in and spits a value out. Something which looks like this (in C#):

float ConvertGramsToOunces(float grams) {
    float ounces = grams * 0.0352739619;
    return ounces;
}

Call it like this:

float grams = 10.0f;
float returnedOunces = ConvertGramsToOunces(grams);

Which would return `0.352739619`.

There. Now all you need to do is write a user interface using the link I provided you and you're all set.