티스토리 뷰

AT 1.1 Q1

// csharp1_1

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

namespace 
{
    class csharp1_1
    {
        static void Main(string[] args)
        {

            int num1, num2, num3;
            Console.WriteLine("Type num1 data : ");
            bool keycheck1 = int.TryParse(Console.ReadLine(), out num1);
            Console.WriteLine("Type num2 data : ");
            bool keycheck2 = int.TryParse(Console.ReadLine(), out num2);
            Console.WriteLine("Type num3 data : ");
            bool keycheck3 = int.TryParse(Console.ReadLine(), out num3);


            if (keycheck1 && keycheck2 && keycheck3)
            {

                if ((num1 > num2) && (num1 > num3))
                {
                    Console.WriteLine("num1 is the largest");

                    if (num2 > num3)
                        Console.WriteLine("num3 is the smallest");
                    else
                        Console.WriteLine("num2 is the smallest");
                }


                else if ((num2 > num1) && (num2 > num3))
                {
                    Console.WriteLine("num2 is the largest");

                    if (num1 > num3)
                        Console.WriteLine("num3 is the smallest");
                    else
                        Console.WriteLine("num1 is the smallest");
                }


                else if ((num3 > num1) && (num3 > num2))
                {
                    Console.WriteLine("num3 is the largest");

                    if (num1 > num2)
                        Console.WriteLine("num2 is the smallest");
                    else
                        Console.WriteLine("num1 is the smallest");
                }

                else
                    Console.WriteLine("Invaild input");

            }

            else
                Console.WriteLine("Invaild input");


            Console.ReadLine();
        }
    }
}
 



AT 1.1 Q2

//csharp1_2

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

namespace 
{
    class csharp1_1
    {
        static void Main(string[] args)
        {

            int num1 = 5;
            int num2 = 10;
            int temp = 0;

            Console.WriteLine("num1 is " + num1);
            Console.WriteLine("num2 is " + num2);

            temp = num1;
            num1 = num2;
            num2 = temp;

            Console.WriteLine("num1 is " + num1);
            Console.WriteLine("num2 is " + num2);

            Console.ReadLine();
        }
    }
}
 


AT 1.1 Q3

//csharp1_3

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

namespace
{
    class csharp1_1
    {
        static void Main(string[] args)
        {
            bool ismale;
            char answer;
            Console.WriteLine("Are you a male? (type y or n) ");
            ismale = char.TryParse(Console.ReadLine(), out answer);

            if (answer == 'y')
                ismale = true;
            else
                ismale = false;

            if (ismale)
                Console.WriteLine("Your gender is male");
            else
                Console.WriteLine("Your gender is female");

            Console.ReadLine();
        }
    }
}




'AU Study > TAFE Assessment' 카테고리의 다른 글

Driving website project  (0) 2017.10.28
c sharp programing at 2 teardown  (0) 2017.10.28
C sharp programming AT 1.2  (0) 2017.10.25
C sharp programming AT 1.4  (0) 2017.10.25
Javascript Portfolio  (0) 2017.10.24
댓글
Announcement
Recent Posts
Recent Comments
Total
Today
Yesterday
Link
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Search by month