习题02 : 程序员相亲遇到三连拷问, 请用代码实现: 女方向程序员提出 你有房子么?你有钱么?你有工作么?三个灵魂拷问
如回答有房子, 直接表示 Let's get married; 愉快的结束相亲
如无房子, 有钱, 则回复Buy a house first;
如无房子,无钱,有工作, 则回复work hard now;
如无房子,无钱,无工作,则江湖再见; 愉快的被结束相亲
尝试了一下 条件运算符 ?,简洁性更好;
Console.WriteLine("Do you have a house?");
String e = Console.ReadLine();
string e1 = (e == "Y") ? "Let's Get married" : "Do you have Money?";
Console.WriteLine(e1);
if (e != "Y")
{
string f = Console.ReadLine();
string f1 = (f == "Y") ? "Buy a house first" : "Do you have a job?";
Console.WriteLine(f1);
if (f != "Y")
{
string g = Console.ReadLine();
string g1 = (g == "Y") ? "work hard now" : "See you";
Console.WriteLine(g1);
}