How To Calculate Triangles Area And Make Operation Do Math Problem With Sharpdevelop #2
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();
Defining result in integer type and equalizing to heibs/2 (heibs/2= triangles area)
Output ;
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();
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 ;
Output Of Code ;
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
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Thank you very much! Fixing now!
Hey @milliar I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
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