4.15代码

/*
string account1 = "admin";
string password1 = "admin2";
Console.WriteLine("请输入用户名:");
string account = Console.ReadLine();
Console.WriteLine("请输入密码:");
string password = Console.ReadLine();
if (account == account1 && password == password1)
Console.WriteLine("登录成功!");
else
Console.WriteLine("用户名密码错误!");
*/
//---------------------------------------------------------------------------------------
/*
while (true)
{
//随机输入一个坐标
Console.WriteLine("请输入X:");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入Y:");
int y = Convert.ToInt32(Console.ReadLine());

if (y == 0 && x == 0)
    Console.WriteLine("点在原点。");
else if (y == 0)
    Console.WriteLine("点在X轴上。");
else if (x == 0)
    Console.WriteLine("点在y轴上。");
else if (x > 0 && y > 0)
    Console.WriteLine("点在第一象限。");
else if (x < 0 && y > 0)
    Console.WriteLine("点在第二象限。");
else if (x < 0 && y < 0)
    Console.WriteLine("点在第三象限。");
else
    Console.WriteLine("点在第四象限。");
}
*/
//-----------------显示最大的数----------------------------------------------------------------------
/*
int a =100, b=80, c=50,max;
if (a > b)
max = a;
else if (b > c)
max = b;
else
max = c;
Console.WriteLine("最大值为:" + max);
*/
//---------------------分段函数------------------------------------------------------------------
/*
Console.WriteLine("请输入X:");
int hsX = Convert.ToInt32(Console.ReadLine());
if (hsX > 0)
Console.WriteLine("y输出为:1");
else if (hsX == 0)
Console.WriteLine("y输出为:0");
else
Console.WriteLine("y输出为:-1");
*/
//---------------------------判断是不是闰年使用三种方式完成 if if..elseif  嵌套----------------------------
/*
Console.WriteLine("请输入年份:");
int year = Convert.ToInt32(Console.ReadLine());
*/
//--------------------------switch case 结构------------------------------------------
Console.WriteLine("请输入月份:");
string month = Console.ReadLine();
Console.WriteLine("请输入年份:");
int year = Convert.ToInt32(Console.ReadLine());
int day;
if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))
day = 29;
else
day = 28;
switch (month)
{
case "1":
case "3":
case "5":
case "7":
case "8":
case "10":
case "12":
    Console.WriteLine("{0}年{1}月有31天",year,month);
    break;
case "4":
case "6":
case "9":
case "11":
    Console.WriteLine("{0}年{1}月有30天", year, month);
    break;
case "2":
    Console.WriteLine("{0}年{1}月有{2}天", year, month,day);
    break;
default:
    Console.WriteLine("输入有误,请重新输入");
    break;
}



//---------------------------------------------------------------------------------------
/*
int iNum = 1;
int iSum = 1;
while (iSum <= 500)
{
iNum += 2;
iSum = iSum + iNum;
}
Console.WriteLine("最小整数为:" + iNum);
*/
Console.ReadKey();

课后作业

//----------------------------P84 1------------------------------------------------------
Console.WriteLine("请输入一个数:");
int num = Convert.ToInt32(Console.ReadLine());
if (num % 2 == 0)
    Console.WriteLine("输入的是偶数");
else
    Console.WriteLine("输入的是奇数");
Console.ReadKey();
//--------------------------------P84 2---------------------------------------------------
Console.Write("请输入银行密码:");
string passWord = Console.ReadLine();
if (passWord == "404328")
    Console.WriteLine("密码正确,你可以取钱了");
else
    Console.WriteLine("密码错误,请重新输入。");
//--------------------------------P87 1-------------------------------------------------------
Console.Write("请输入报销金额:");
int money = Convert.ToInt32(Console.ReadLine());
if (money < 5000)
    Console.WriteLine("正常报销");
else
    Console.WriteLine("不符合规定报销");
//--------------------------------P87 2-------------------------------------------------------
Console.Write("请输入电话号码:");
string phoeNumber = Console.ReadLine();
if (phoeNumber == "134256431")
    Console.WriteLine("电话正在接通,请稍后。。。");
else
    Console.WriteLine("您所拨打的电话不存在!");
//--------------------------------P90 2-------------------------------------------------------
Console.Write("请输入成绩:");
int grade = Convert.ToInt32(Console.ReadLine());
if (grade > 85)
    Console.WriteLine("成绩优秀");
else if (grade > 75)
    Console.WriteLine("成绩良好");
else if (grade > 60)
    Console.WriteLine("成绩中等");
else
    Console.WriteLine("成绩差");
//--------------------------------P90 2-------------------------------------------------------
int YouAge = 0;
Console.WriteLine("请输入你的年龄:");
YouAge = int.Parse(Console.ReadLine());
if (YouAge <= 18)
    Console.WriteLine("年龄还小,需要继续努力奋斗");
else if (YouAge > 18 && YouAge <= 30)
    Console.WriteLine("努力奋斗的黄金阶段");
else if (YouAge > 30 && YouAge <= 50)
    Console.WriteLine("人生的黄金阶段");
else
    Console.WriteLine("最美不过夕阳红");
//--------------------------------P92 2-------------------------------------------------------
Console.WriteLine("请输入到访客人人数:");
int num = Convert.ToInt32(Console.ReadLine());
if (num <= 4)
    Console.WriteLine("请到4人桌就餐");
else if (num <= 6)
    Console.WriteLine("请到6人桌就餐");
else if (num <= 10)
    Console.WriteLine("请到10人桌就餐");
else
    Console.WriteLine("抱歉,没有这么大的包间");
//--------------------------------P92 2-------------------------------------------------------

Console.WriteLine("请输入累计消费金额:");
int sale = Convert.ToInt32(Console.ReadLine());
switch(sale/200)
{
    case 0:
        Console.WriteLine("你已消费{0}元,暂无优惠的!",sale);
        break;
    case 1:
    case 2:
        Console.WriteLine("你已消费{0}元,可享受8.5折优惠,即优惠{1}元!",sale,sale*0.15);
        break;
    case 3:
    case 4:
        Console.WriteLine("你已消费{0}元,可享受7折优惠,即优惠{1}元!", sale, sale * 0.3);
        break;
    default:
        Console.WriteLine("你已消费{0}元,可享受6折优惠,即优惠{1}元!", sale, sale * 0.4);
        break;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值