A calculator which converts the weight from earth gravity to moon.Code example in C#

In the follow lines it is presented an example of code which calculates and convert the moon weight with the acceptance that the weight on  moon is 17% of earh ‘s weight.It is a proposal solution of an exercise in the book “The guide of C# 3.0 .(Herbert Schildt-Mc Graw Hill”).All you have to do is to is to run it as console application in Visual Studio.

************************************************************************************************************************************************************************************************************************************************************************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)

{
int st = 17;
float earth_gravity, moon_gravity;
Console.WriteLine(“Give earth weight \t”);

earth_gravity=Convert.ToInt32(Console.ReadLine());
Console.ReadLine();

moon_gravity= earth_gravity*st/100;

Console.WriteLine(“The weight in moon is ” + moon_gravity);
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s