SlideShare a Scribd company logo
1 of 2
using   System;
using   System.Collections.Generic;
using   System.Linq;
using   System.Text;
using   System.IO;

namespace ConsoleApplication20
{
    class triangle
    {
        float bas;
        float perp;
        //float getperp;
        //float getbase;
        double area;
        double hypotnuse;
        public void setbase(float newvalue)
        {
            //Console.WriteLine("enter the first value?");
            //bas=Convert.ToSingle(Console.ReadLine());
            bas = newvalue;


         }
         public float getbase()
         {
             Console.WriteLine("enter the value of base?");
             bas = Convert.ToSingle(Console.ReadLine());

             return bas;
         }
         public void setperp(float newvalue)
         {
             perp = newvalue;

         }
         public float getperp()
         {
             Console.WriteLine("enter the value of perpendicular?");
             perp = Convert.ToSingle(Console.ReadLine());
             return perp;

         }
         public double getarea()
         {
             area = 0.5 * bas * perp;
             return area;


         }
         public double gethypotneus()
         {
             hypotnuse = Math.Sqrt((bas * bas) + (perp * perp));

              return hypotnuse;
         }


    }
    class Program
    {
        static void Main(string[] args)
        {
            triangle tr = new triangle();
tr.getperp();
            tr.getbase();
            tr.gethypotneus();
            tr.getarea();
            Console.WriteLine("Hypotnuse={0}", tr.gethypotneus());
            Console.WriteLine("Area = {0}", tr.getarea());
        }
    }
}

More Related Content

What's hot (8)

Convert bilangan
Convert bilanganConvert bilangan
Convert bilangan
 
Colecções C#
Colecções C#Colecções C#
Colecções C#
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Stack demo - copy
 Stack demo - copy Stack demo - copy
Stack demo - copy
 
Control lec 2
Control lec 2Control lec 2
Control lec 2
 
Osmose
OsmoseOsmose
Osmose
 
filter design using matlab
filter design using matlabfilter design using matlab
filter design using matlab
 
Ejerc3 141204195452-conversion-gate01
Ejerc3 141204195452-conversion-gate01Ejerc3 141204195452-conversion-gate01
Ejerc3 141204195452-conversion-gate01
 

Viewers also liked

รูปแบบของภาพกราฟิกที่ใช้งานบนเว็บเพจ
รูปแบบของภาพกราฟิกที่ใช้งานบนเว็บเพจรูปแบบของภาพกราฟิกที่ใช้งานบนเว็บเพจ
รูปแบบของภาพกราฟิกที่ใช้งานบนเว็บเพจaomaommee
 
Manufacturing processes
Manufacturing processesManufacturing processes
Manufacturing processesArpit Goel
 
C07 hands on_defense_antibacterial_flyer-signed
C07 hands on_defense_antibacterial_flyer-signedC07 hands on_defense_antibacterial_flyer-signed
C07 hands on_defense_antibacterial_flyer-signedDeborah Hunter
 
Useful commands
Useful commandsUseful commands
Useful commandsArpit Goel
 
Unity and coherence
Unity and coherenceUnity and coherence
Unity and coherenceLori Ward
 

Viewers also liked (8)

More servers
More serversMore servers
More servers
 
รูปแบบของภาพกราฟิกที่ใช้งานบนเว็บเพจ
รูปแบบของภาพกราฟิกที่ใช้งานบนเว็บเพจรูปแบบของภาพกราฟิกที่ใช้งานบนเว็บเพจ
รูปแบบของภาพกราฟิกที่ใช้งานบนเว็บเพจ
 
Manufacturing processes
Manufacturing processesManufacturing processes
Manufacturing processes
 
Readme!
Readme!Readme!
Readme!
 
C07 hands on_defense_antibacterial_flyer-signed
C07 hands on_defense_antibacterial_flyer-signedC07 hands on_defense_antibacterial_flyer-signed
C07 hands on_defense_antibacterial_flyer-signed
 
Useful commands
Useful commandsUseful commands
Useful commands
 
Unity and coherence
Unity and coherenceUnity and coherence
Unity and coherence
 
Chapter 001
Chapter 001Chapter 001
Chapter 001
 

Triangle

  • 1. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication20 { class triangle { float bas; float perp; //float getperp; //float getbase; double area; double hypotnuse; public void setbase(float newvalue) { //Console.WriteLine("enter the first value?"); //bas=Convert.ToSingle(Console.ReadLine()); bas = newvalue; } public float getbase() { Console.WriteLine("enter the value of base?"); bas = Convert.ToSingle(Console.ReadLine()); return bas; } public void setperp(float newvalue) { perp = newvalue; } public float getperp() { Console.WriteLine("enter the value of perpendicular?"); perp = Convert.ToSingle(Console.ReadLine()); return perp; } public double getarea() { area = 0.5 * bas * perp; return area; } public double gethypotneus() { hypotnuse = Math.Sqrt((bas * bas) + (perp * perp)); return hypotnuse; } } class Program { static void Main(string[] args) { triangle tr = new triangle();
  • 2. tr.getperp(); tr.getbase(); tr.gethypotneus(); tr.getarea(); Console.WriteLine("Hypotnuse={0}", tr.gethypotneus()); Console.WriteLine("Area = {0}", tr.getarea()); } } }