namespace 作业
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个数字:");
int day = int.Parse(Console.ReadLine());
switch (day)
{
case 1:
case 2:
case 3:
case 4:
case 5:
Console.WriteLine("今天是工作日");
break;
case 6:
case 7:
Console.WriteLine("今天是休息日");
break;
default:
Console.WriteLine("您的输入无效");
break;
}
Console.WriteLine("请输入成绩");
int score = int.Parse(Console.ReadLine());
if (score > 100 || score < 0)
{
Console.WriteLine("输入不合法");
}
else // 表示 score<=100 && score>=0
{
switch (score / 10)
{
case 10:
Console.WriteLine("满分");
break;
case 9:
Console.WriteLine("优秀");
break;
case 8:
case 7:
Console.WriteLine("良好");
break;
case 6:
Console.WriteLine("及格");
break;
default:
Console.WriteLine("不及格");
break;
}
}
Console.WriteLine("选择性别0:男\t1:女");
int gender = int.Parse(Console.ReadLine());
Console.WriteLine("请输入体重");
int weight = int.Parse(Console.ReadLine());
Console.WriteLine("请输入身高");
int height = int.Parse(Console.ReadLine());
//记录标准的体重
int standerWeight = 0;
switch (gender)
{
case 0:
standerWeight = height - 105;
break;
case 1:
standerWeight = height - 100;
break;
default:
Console.WriteLine("不存在此性别");
break;
}
float rate = weight * 1.0f / standerWeight;
if (rate < 0.6f)
{
Console.WriteLine("严重营养不良");
}
else if (rate < 0.8f) // rate>=0.6 && rate<0.8
{
Console.WriteLine("中度营养不良");
}
else if (rate < 0.9)
{
Console.WriteLine("轻度营养不良");
}
else if (rate < 1.1)
{
Console.WriteLine("正常");
}
else if (rate < 1.2)
{
Console.WriteLine("轻度肥胖");
}
else
{
Console.WriteLine("肥胖");
}
Console.WriteLine("请输入学员成绩");
int score = int.Parse(Console.ReadLine());
char level = 'A';
switch (score / 10)
{
case 10:
case 9:
level = 'A';
break;
case 8:
level = 'B';
break;
case 7:
level = 'C';
break;
case 6:
level = 'D';
break;
default:
level = 'E';
break;
}
Console.WriteLine(level);
Console.WriteLine("请输入年份");
int year = int.Parse(Console.ReadLine());
Console.WriteLine("请输入月份");
int month = int.Parse(Console.ReadLine());
Console.WriteLine("请输入日期");
int days = int.Parse(Console.ReadLine());
//记录累加的天数
//2 20
int totalDays = 0;
totalDays += days;
month -= 1;
if (month==11)
{
totalDays += 30;
month -= 1;
}
if (month == 10)
{
totalDays += 31;
month -= 1;
}
if (month == 9)
{
totalDays += 30;
month -= 1;
}
if (month == 8)
{
totalDays += 31;
month -= 1;
}
if (month == 7)
{
totalDays += 31;
month -= 1;
}
if (month == 6)
{
totalDays += 30;
month -= 1;
}
if (month == 5)
{
totalDays += 31;
month -= 1;
}
if (month == 4)
{
totalDays += 30;
month -= 1;
}
if (month == 3)
{
totalDays += 31;
month -= 1;
}
//能执行下面的if条件的 肯定是大于2月份的
if (month == 2)
{
totalDays += 28;
month -= 1;
//判断是否为闰年 是闰年再加1
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
totalDays++;
}
}
if (month == 1)
{
totalDays += 31;
month -= 1;
}
Console.WriteLine("这是今年的第{0}天",totalDays);
}
}
}
C#基础-017 简单练习-循环
最新推荐文章于 2023-10-28 10:21:16 发布