How To Calculate Triangles Area And Make Operation Do Math Problem With Sharpdevelop #2

in #utopian-io6 years ago (edited)

What Will I Learn?

Hey there,in this tutorial we are getting into some math any geometry problems.

  • You will learn how to calculate triangles area with coding c# in sharpdevelop
  • You will learn how to use c# coding to calculate though math and geometry problems

Requirements

  • SharpDevelop
  • Basic knowledge of coding
  • Basic knowledge of math and geometry

Difficulty

  • Basic

Tutorial Contents

In this tutorial we are starting to find out how to calculate geometric shapes area.I'm going to show you how to calculate triangles area with coding c# in sharpdevelop.I'm planning to make a lot c# course to make you will learn c# from the beginning.I'm assumming you g know the loops etc.I will start from basic and in next tutorials i will give you tutorials in a college level.Let's get it started with triangle.

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

Don't forget to define your libraries.

class Program
static void Main(string[] args)

int hei, bs;

Defining height and base in integer type.

Console.Write("Enter triangles height...:");
hei = Convert.ToInt16(Console.ReadLine());

Asking user to enter triangles height and converting "hei" to 16bytes integer.

Console.Write("Enter triangles base...:");
bs = Convert.ToInt16(Console.ReadLine());

Asking user to enter triangles base and converting "bs" to 16bytes integer.

int result = hei * bs / 2;
Console.WriteLine("Triangles area : " + result.ToString());
Console.ReadLine();

1.png

Defining result in integer type and equalizing to heibs/2 (heibs/2= triangles area)

Output ;

2.png

Let's get to the second project

In this project we will ask user to enter two number then we will ask to enter a operation to user again and code will solve the rest... Let's get it started.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tutorial2
class Program
static void Main(string[] args)

I will always add libraries in these tutorials because these tutorials are basic level and i want to remind you that you need to add these....

double s1, s2;
Console.WriteLine("Enter two number...: ");
s1 = double.Parse(Console.ReadLine());
s2 = double.Parse(Console.ReadLine());

Defining s1,s2 in double type because they can be fractional,double.parse
consverts a string representation of a number to its double precision floating-point number equivalent.

Console.WriteLine("Enter the operation..: (+, -, *, /)");
string operation = Console.ReadLine();

4.png

Asking user to enter an operation

if (operation == "+")
Console.WriteLine("Additions Result..:" + (s1 + s2));

If user entered + making our code to do addition

else if (operation == "-")
Console.WriteLine("Subtractions Result..:" + (s1 - s2));

If user entered - making our code to do extraction

else if (operation == "*")
Console.WriteLine("Multiplications Result.:" + (s1 * s2));

If user entered * making our code to do multiplication

else if (operation == "/")
Console.WriteLine("Divisions Result..:" + (s1 / s2));

If user entered / making our code to do division

else
Console.WriteLine("You have entered a wrong value....");
Console.ReadKey();

If user entered something else than our defined operations this line will be in charge

Full code ;
3.png

Output Of Code ;

5.png

6.png

Curriculum

If you want to start from somewhere in c# coding keep up with me.More to come if approved...

First tutorial below



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

Thank you very much! Fixing now!

Hey @milliar I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64724.35
ETH 3436.21
USDT 1.00
SBD 2.55