第13题:
①让用户输入的年龄大于23(含)岁,则给用户显示你到了结婚的年龄了。
②如果老苏的(chinese music)
语文成绩大于90并且音乐成绩大于80或
语文成绩等于100并且音乐成绩大于70,则奖励100元
③让用户输入用户名和密码,如果用户名为admin,密码为mypass,则提示登陆成功。
①:
using System;
namespace 练习题13
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入你的年龄");
int age = Convert.ToInt32(Console.ReadLine());
if(age>=20)
{
Console.WriteLine("你可以结婚啦");
}
Console.ReadKey();
}
}
}
②:
using System;
namespace 练习题13
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入老苏的语文成绩");
int chinese = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入老苏的音乐成绩");
int music = Convert.ToInt32(Console.ReadLine());
bool b = (chinese > 90 && music > 80) || (chinese == 100 && music > 70);
if (b)
{
Console.WriteLine("奖励100元");
}
Console.ReadKey();
}
}
}
③:
using System;
namespace 练习题13
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入用户名");
string name = Console.ReadLine();
Console.WriteLine("请输入密码");
string pwd = Console.ReadLine();
if (name=="admin "&& pwd=="mypass")
{
Console.WriteLine("登录成功");
}
Console.ReadKey();
}
}
}
第14题:
using System;
namespace 练习题14
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入学员的考试成绩");
int score = Convert.ToInt32(Console.ReadLine());
if(score>=90)
{
Console.WriteLine("A");
}
else
{
if(score>=80)
{
Console.WriteLine("B");
}
else
{
if(score>=70)
{
Console.WriteLine("C");
}
else
{
if(score>=60)
{
Console.WriteLine("D");
}
else
{
Console.WriteLine("E");
}
}
}
}
Console.ReadKey();
}
}
}