Tuesday, 23 December 2014

PROGRAM IN CSHARP TAKE INPUT FROM USER TO PERFORM ADDITION-SUBTRACTION-MULTIPLICATION-DIVISION|TO GET TABLE|TO GET PROFILE OF USER|EXIT

PROGRAM IN C#(SHARP) FOR TAKE INPUT FROM USER TO PERFORM ADDITION,SUBTRACTION,MULTIPLICATION,DIVISION AND TO GET TABLE AND
TO GET PROFILE OF USER AND THEN EXIT

PROGRAM

using System;

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("choose any one");
            Console.WriteLine("1= Add");
            Console.WriteLine("2= sub");
            Console.WriteLine("3= multiply");
            Console.WriteLine("4= divide");
            Console.WriteLine("5= table");
            Console.WriteLine("6= sum with dicount");
            Console.WriteLine("7= profile ");
            Console.WriteLine("8= exit");
            int choice = int.Parse(Console.ReadLine());
            int num1;
            int num2;
            int num3;
            float num4;
            switch (choice)
            {
                case 1:
                     Console.WriteLine("You have choose addition");
                     Console.WriteLine("enter 2 number");
                      num1 = int.Parse(Console.ReadLine());
                      num2 = int.Parse(Console.ReadLine());
                     Console.WriteLine(num1+num2);
                     break;

                case 2:
                    Console.WriteLine("You have choose Subs");
                     Console.WriteLine("enter 2 number");
                      num1 = int.Parse(Console.ReadLine());
                      num2 = int.Parse(Console.ReadLine());
                     Console.WriteLine(num1 - num2);
                     break;

                case 3:
                    Console.WriteLine("You have choose multiply");
                     Console.WriteLine("enter 2 number");
                      num1 = int.Parse(Console.ReadLine());
                      num2 = int.Parse(Console.ReadLine());
                     Console.WriteLine(num1 * num2);
                     break;

                case 4:
                    Console.WriteLine("You have choose divide");
                     Console.WriteLine("enter 2 number");
                      num1 = int.Parse(Console.ReadLine());
                      num2 = int.Parse(Console.ReadLine());
                     Console.WriteLine(num1 / num2);
                     break;
                case 5:
                     Console.WriteLine("You have choose table");
                     Console.WriteLine("enter number");
                     num1 = int.Parse(Console.ReadLine());

                     for (int tab=1 ; tab<=10 ; tab++)
                     {
                         num3=num1*tab;
                         Console.WriteLine(num1+"x"+ tab +"="+ num3);
                     }
                     break;

                case 6:
                     Console.WriteLine("You have choose sum with discount");
                     Console.WriteLine("enter 2 number");
                     float num11 = float.Parse(Console.ReadLine());
                     float num22 = float.Parse(Console.ReadLine());
                     Console.WriteLine("enter discount in percentage");
                     float num33 = float.Parse(Console.ReadLine());
                    
                        float  sum = num11 + num22;
                        float  discount = num33 / 100;
                        num4 = sum * discount;
                        float final = sum - num4;
                         Console.WriteLine(final);
                    
                     break;
                case 7:
                     Console.WriteLine("You have choose profile");
                     Console.WriteLine("enter your name");
                     string name = (Console.ReadLine());
                    Console.WriteLine("enter your father name");
                     string fname = (Console.ReadLine());
                    Console.WriteLine("enter your gender");
                     string gen = (Console.ReadLine());
                    Console.WriteLine("enter your city name");
                    string city  = (Console.ReadLine());
                    Console.WriteLine("your name is "+name);
                    Console.WriteLine("your father name is "+fname);
                    Console.WriteLine("your are "+gen);
                    Console.WriteLine("your number is "+city);
                    
                     break;
                case 8:
                       
                     break;
                default:
                    Console.WriteLine("wrong choice plz run programm again");
                    break;


            }
        }
    }

0 comments:

Post a Comment