Showing posts with label console based. Show all posts
Showing posts with label console based. Show all posts

Saturday, 23 July 2011

some logic building question code

Question1

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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int age;
            int a, b, c;
            Console.WriteLine("Enter your Current Age");
            age= Convert.ToInt32(Console.ReadLine());
            if (age < 18)
            {
                Console.WriteLine("You are a Child");
            }
            else if (18 <=age)
            {
                Console.WriteLine("You are Adult");
            }
            else
            {
                 Console.WriteLine("You are a Child");
            }
            Console.ReadKey();
        }
    }
}



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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
          
            for (a = 1; a <=100 ;a++ )
            {
                if (a % 2 !=0 && a % 3 != 0 && a % 5 != 0)
                {
                 
                    Console.WriteLine("{0}",a);
                }

            }
            Console.ReadKey();
        }
    }
}



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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            for (a = 0; a <= 255; a++)
            {
                Console.WriteLine("{0} --->{1}", a,Convert.ToChar(a));


            }
            Console.ReadKey();
        } 
    }
}



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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            int b;
           int c;
            Console.WriteLine("what your want to do *,+,-,/  select one");
            c = Convert.ToChar(Console.ReadLine());
            Console.WriteLine("Enter First Number");
            a = Convert.ToInt32(Console.ReadLine());
    

            Console.WriteLine("Enter Second Number");
            b = Convert.ToInt32(Console.ReadLine());
            switch (c)
            {
                case '*':
                    c = a * b;
                    Console.WriteLine("The Mul of a and b {0}", c);
                    break;
                case '+':
                    c = a + b;
                    Console.WriteLine("The sum of a & b {0}", c);
                    break;
                case '-':
                    c = a - b;
                    Console.WriteLine("The difference of a & b {0}", c);
                    break;
                case '/':
                    c = a / b;
                    Console.WriteLine("The quotient of a & b {0}", c);
                    break;
            }
            Console.ReadKey();

        }
    }
}


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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            int b;
            
            Console.WriteLine("Enter Number for Table");
            a = Convert.ToInt32(Console.ReadLine());
            for (b = 1; b <= 10; b++)
            {
               
                Console.WriteLine("{0}X {1}={2}",a, b,a*b);
            }
            Console.ReadKey();
        }
    }
}


salary calculator


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int mon,tues,wed,thurs,fri;
            int twhour, salrary;
            int ovtime;

            Console.WriteLine("working hour of monday");
            mon = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("working hour of tuesday");
            tues = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("working hour of wedday");
            wed = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("working hour of thursday");
            thurs = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("working hour of friday");
            fri = Convert.ToInt32(Console.ReadLine());

            twhour = mon + tues + wed + thurs + fri;
            Console.WriteLine("the total working hour is {0}",twhour);

            salrary = twhour * 500;
            Console.WriteLine("the total salary is {0} $", salrary);

            if(twhour>40)
            {
                ovtime = twhour - 40;
                Console.WriteLine("over time hour are{0} ",ovtime);
            }
            Console.ReadKey();
        }
    }
}