Showing posts with label C# LAB at HoM 9. Show all posts
Showing posts with label C# LAB at HoM 9. Show all posts

Tuesday, 30 April 2013

Sam is working on an application wherein he needs to accept the size of a one dimensional array and its values. He needs to identify the largest and smallest number in the array and based on that he needs to display the result. Help him to create the application.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] io=new int[3]{5,4,6};
            Console.WriteLine("Sam is working on an application wherein he needs to accept the size of a one dimensional array and its values. He needs to identify the largest and smallest number in the array and based on that he needs to display the result. Help him to create the application.  ");
            if(io[0]>io[1] && io[0]>io[2])
            {
                Console.WriteLine("the largest number is:" + io[0]);
            }
            if (io[1] > io[0] && io[1] > io[2])
            {
                Console.WriteLine("the largest number is:" + io[1]);
            }
            if (io[2] > io[0] && io[2] > io[1])
            {
                Console.WriteLine("the largest number is:" + io[2]);
            }
            if (io[0] < io[1] && io[0] < io[2])
            {
                Console.WriteLine("the smallest number is:" + io[0]);
            }
            if (io[1] < io[0] && io[1] < io[2])
            {
                Console.WriteLine("the smallest number is:" + io[1]);
            }
            if (io[2] < io[0] && io[2] < io[1])
            {
                Console.WriteLine("the smallest number is:" + io[2]);
            }
            Console.ReadLine();
        }
    }
}

Saturday, 27 April 2013

lab @ home 10

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication4



{
class duplicate



{
static void Main(string[] args)



{
char[] ch = new char[5] { 'a', 'b', 'a', 'c', 'd' };

int i, count = 0;

Console.WriteLine("enter a character:");

char input = Convert.ToChar(Console.ReadLine());

for (i = 0; i < 5; i++)



{
if (ch[i] == input)



{

count++;

}

}


Console.WriteLine("{0} appears {1} times in the character array", input, count);

Console.ReadLine();





}

}

}

Thursday, 25 April 2013

David needs to create a program to maintain the details of the stock of a shop. He needs to ensure that item category is Women, Men, Girls, Boys, and Babies. He needs to accept item category from the user. In addition, he needs to accept item name, number of units, and unit price. Finally, he needs to display all the details.


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

namespace ConsoleApplication27
{
    class shop
    {
        string item;
        int up, total, unit;
        public void accept()
        {
            Console.WriteLine("Enter the item name:");
            item = Convert.ToString(Console.ReadLine());
            Console.WriteLine("Enter units of item:");
            unit = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter the unnit price:");
            up = Convert.ToInt32(Console.ReadLine());

        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string cat;
            shop s = new shop();
            Console.WriteLine("Enter the catagory:");
            cat = Convert.ToString(Console.ReadLine());
            switch (cat)
            {
                case "women":
                    s.accept();
                    break;
                case "men":
                    s.accept();
                    break;
                case "girls":
                    s.accept();
                    break;
                case "boys":
                    s.accept();
                    break;
                case "babies":
                    s.accept();
                    break;
                default:
                    Console.WriteLine("Invalid Selection");
                    break;
            }
            Console.ReadLine();
        }
    }
}