zoukankan      html  css  js  c++  java
  • c#基础练习之if结构

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

    namespace if语句
    {
        class Program
        {
            static void Main(string[] args)
            {

                 //如果张三的考试成绩大于90,那么爸爸奖励他100块钱。

                Console.WriteLine("请输入张三的成绩");
                int cj = Convert.ToInt32(Console.ReadLine());
                if (cj > 90)
                {
                /   Console.WriteLine("爸爸奖励100元");
                }
                else
                {
                  Console.WriteLine("爸爸让写总结");
                }
                Console.ReadKey();

                   //2如果张三的语文成绩大于90并且音乐成绩大于80,或者语文成绩等于100并且音乐成绩大于70,则奖励100元。

               Console.WriteLine("请输入张三的语文成绩");
               int chinese = Convert.ToInt32(Console.ReadLine());
               Console.WriteLine("请输入张三的音乐成绩");
               int yinyue = Convert.ToInt32(Console.ReadLine());
               bool cj; 
                if (cj = chinese > 90 && yinyue > 80 || chinese == 100 && yinyue > 70)
                {
                    Console.WriteLine("爸爸奖励100元");
                }

                Console.ReadKey();

                ///3对结业考试成绩测评(要求用户输入一个具体成绩0-100分,程序根据成绩显示一个等级)
                (考虑用if还是用if-else)
                 成绩>=90   A
                90> 成绩>=80   B
                80> 成绩>=70   C
                70> 成绩>=60   D
               成绩<60   E
                Console.WriteLine("请您输入一个具体的成绩");
                int cj = Convert.ToInt32(Console.ReadLine());
                if (cj >= 90)
              {
                    Console.WriteLine("A");
                }
           if (cj < 90 && cj >= 80)
              {
                    Console.WriteLine("B");
                }
                if (cj < 80 && cj >= 70)
                {
                    Console.WriteLine("C");
                }
                if (cj < 70 && cj >= 60)
                {
                   Console.WriteLine("D");
                }
                if  (cj<60)
                {
                  Console.WriteLine("E");
                }
                Console.ReadKey();

                ///4.要求用户输入两个数a和b,如果a能够被b整除或者a加b大于100,则输出a否则输出b。
                Console.WriteLine("请您输入一个数字");
                int a = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("请您输入一个数字");
                int b = Convert.ToInt32(Console.ReadLine());
                if (a % b == 0 || a + b > 100)
                {c
                   Console.WriteLine("a");
                }
                else
                {
                    Console.WriteLine("b");
                }
                Console.ReadKey();

    //6.让用户输入用户名和密码,如果用户名为admin,密码为mypass,则提示登录成功。

                Console.WriteLine("请您输入密码:");
                int password = Convert.ToInt32(Console.ReadLine());
             
               
                    if (password == 888888)
                    {
                        Console.WriteLine("正确");

                    }
                     if (password != 888888)
                    {
                        Console.WriteLine("请您重新输入");
                    }
                     if (password == 888888)
                    {
                         Console.WriteLine("正确");
                     }
               
                  Console.ReadKey();
            }
        }
    }

  • 相关阅读:
    二读《活着》有感
    Linux系统上安装JDK和Tomcat服务器
    在阿里云服务器上安装完成并启动Tomcat后,通过http不能访问--解决办法
    安装JDK出现错误:-bash: /usr/java/jdk1.7.0_71/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory解决办法
    python结巴(jieba)分词
    mysql数据库优化
    ansible常见模块
    CentOS6.5 64位下安装部署Ansible
    [Python] 利用commands模块执行Linux shell命令
    python迭代器
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3144873.html
Copyright © 2011-2022 走看看