当前位置:网站首页>C # exchange number, judge to pass the exam

C # exchange number, judge to pass the exam

2022-07-07 23:33:00 Bobo in summer

 static void Swap( ref int x, ref int y)
         {
    
             int temp;
             temp = x;
             x = y;
             y = temp;
        }
            int m = 2, n = 3;
            Console.WriteLine(" Exchange before , Two Numbers {0} and {1}",m,n);
            Swap(ref m,ref n);
            Console.WriteLine(" After exchanging , Two Numbers {0} and {1}", m,n);
            Console.ReadKey();

 Insert picture description here

class Student
    {
    
       public  string name;
         int Score;
         public int Score1
        {
    
            get {
     return Score; }
            set {
    
                Score = value;
                if (value >= 0 && value <= 100)
                {
    
                    Score = value;
                }
                else
                    Score = -1;
            }
        }
    }

            Student stu = new Student();
            Console.WriteLine(" Please enter your name ");
            stu.name = Console.ReadLine();
            Console.WriteLine(" Please enter your score ");
            stu.Score1 = int.Parse(Console.ReadLine());
            if (stu.Score1 == -1)
            {
    
                Console.WriteLine(" data is invalid ");
            }
            else
            {
    
                if (stu.Score1 >= 60 && stu.Score1 <= 100)
                {
    
                    Console.WriteLine(" You have passed the exam ");
                }
                else if (stu.Score1 <= 60)
                {
    
                    Console.WriteLine(" Failed the exam ");
                }
            }
            Console.ReadKey();

 Insert picture description here

原网站

版权声明
本文为[Bobo in summer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130558212208.html