那个给详细讲下:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入你的名字:");
string name = Convert.ToString(Console.ReadLine());
Console.Write("{0} :你好!\n请输入你家本月用水量:",name);
double ysl,feiyong;
ysl = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("你本月的用水量为:{0}",ysl+"吨");
//if (ysl <= 3.5)
//{
// ysl = ysl * 2.8;
// Console.WriteLine("你应该支付本月水费:{0}", ysl + " 元");
//}
//else
//{
// ysl = ysl * 4.2;
// Console.WriteLine("你应该支付本月水费:{0}", ysl + " 元");
//}
feiyong = shuifei(ys);
Console.WriteLine("你应该支付本月水费:{0}", feiyong + " 元");
Console.ReadLine();
}
static double shuifei (double ys)
{
if(ys <= 3.5)
{
return 2.8 * ys;
}
else
return 4.2 * ys;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入你的名字:");
string name = Convert.ToString(Console.ReadLine());
Console.Write("{0} :你好!\n请输入你家本月用水量:",name);
double ysl,feiyong;
ysl = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("你本月的用水量为:{0}",ysl+"吨");
//if (ysl <= 3.5)
//{
// ysl = ysl * 2.8;
// Console.WriteLine("你应该支付本月水费:{0}", ysl + " 元");
//}
//else
//{
// ysl = ysl * 4.2;
// Console.WriteLine("你应该支付本月水费:{0}", ysl + " 元");
//}
feiyong = shuifei(ys);
Console.WriteLine("你应该支付本月水费:{0}", feiyong + " 元");
Console.ReadLine();
}
static double shuifei (double ys)
{
if(ys <= 3.5)
{
return 2.8 * ys;
}
else
return 4.2 * ys;
}
}
}
feiyong = shuifei(ysl);