C# 优化150行代码以实现简单的功能
我需要帮助优化我用C#编写的一段代码。现在很邋遢。我需要编写一个代码,根据患者数量跟踪医院在一天中的收入。以下是一些条件和细节:C# 优化150行代码以实现简单的功能,c#,C#,我需要帮助优化我用C#编写的一段代码。现在很邋遢。我需要编写一个代码,根据患者数量跟踪医院在一天中的收入。以下是一些条件和细节: 代码必须显示患者的成本和一天结束时赚的钱的数量 当同一患者一次性完成无线电图像和会诊时,无线电图像的价格会降低25% 当患者进行会诊、血液检查和注射时。那个人交税后得到10美元 注射剂可以是30ml、50ml或60ml。价格与注射的产品数量成比例。(例如:20岁的人如果要注射50毫升,必须支付25美元) 税是15% ======== 下面是我为这个问题编写的
- 代码必须显示患者的成本和一天结束时赚的钱的数量
- 当同一患者一次性完成无线电图像和会诊时,无线电图像的价格会降低25%
- 当患者进行会诊、血液检查和注射时。那个人交税后得到10美元
- 注射剂可以是30ml、50ml或60ml。价格与注射的产品数量成比例。(例如:20岁的人如果要注射50毫升,必须支付25美元)
- 税是15%
int client;
int clientfinal = 0;
double injprix = 0;
double consprix = 0;
double imgradprix = 0;
double analyzeprix = 0;
double prixtot = 0;
double prixclient = 0;
double prixfinal = 0;
int injtaille = 0;
string cons, inj, imgrad, analyze;
Console.WriteLine("Combien a t-il de client aujourd'hui?");
client = (Convert.ToInt32(Console.ReadLine()));
if (client > 0)
do //un client
{
Console.WriteLine("Quel est l'age du patient?");
client = Convert.ToInt32(Console.ReadLine());
if (client < 12)
{
client = 1;
}
if (client >= 12 || client <= 18)
{
client = 2;
}
if (client >= 19 || client <= 65)
{
client = 3;
}
if (client > 65)
{
client = 4;
}
Console.WriteLine("La personne a t-elle choisit une consultation?");
cons = Convert.ToString(Console.ReadLine()).ToLower();
Console.WriteLine("La personne a t-elle choisit une image radio?");
imgrad = Convert.ToString(Console.ReadLine()).ToLower();
Console.WriteLine("La personne a t-elle choisit une analyze de sang?");
analyze = Convert.ToString(Console.ReadLine()).ToLower();
Console.WriteLine("La personne a t-elle choisit une injection?");
inj = Convert.ToString(Console.ReadLine()).ToLower();
if (inj == "oui")
{
Console.WriteLine("Quel est la taille de l'injection? (30 - 50 - 60) ");
injtaille = Convert.ToInt32(Console.ReadLine());
}
switch (client)
{
case 1:
consprix = 25;
imgradprix = 55;
analyzeprix = 28;
injprix = 0;
break;
case 2:
consprix = 32;
imgradprix = 65;
analyzeprix = 32;
switch (injtaille)
{
case 30:
injprix = 13;
break;
case 50:
injprix = (650 / 30);
break;
case 60:
injprix = (780 / 30);
break;
default:
Console.WriteLine("Taille d'injection inconnue.");
break;
}
break;
case 3:
consprix = 40;
imgradprix = 70;
analyzeprix = 40;
switch (injtaille)
{
case 30:
injprix = 13;
break;
case 50:
injprix = (750 / 30);
break;
case 60:
injprix = (900 / 30);
break;
default:
Console.WriteLine("Taille d'injection inconnue.");
break;
}
break;
case 4:
consprix = 30;
imgradprix = 60;
analyzeprix = 35;
switch (injtaille)
{
case 30:
injprix = 13;
break;
case 50:
injprix = (600 / 30);
break;
case 60:
injprix = (720 / 30);
break;
default:
Console.WriteLine("Taille d'injection inconnue.");
break;
}
break;
}
//Fin Switch
if (imgrad == "non")
{
imgradprix = 0;
}
if (cons == "non")
{
consprix = 0;
}
if (analyze == "non")
{
analyzeprix = 0;
}
if (inj == "non")
{
injprix = 0;
}
if (imgrad == "oui" || cons == "oui")
{
imgradprix = imgradprix * 0.75;
}
prixclient = consprix + imgradprix + analyzeprix + injprix;
prixclient = prixclient * 1.15;
if (cons == "oui" || analyze == "oui" || inj == "oui")
{
prixclient = prixclient - 10;
}
prixtot += prixclient;
clientfinal++;
prixfinal = prixtot;
Console.WriteLine("Prix du patient " + prixclient);
} while (clientfinal != client);
Console.WriteLine("Le prix final est" + prixfinal);
}
}
int客户端;
int clientfinal=0;
双injprix=0;
双conprix=0;
双imgradprix=0;
双重分析prix=0;
双prixtot=0;
双优先级客户端=0;
双prixfinal=0;
int injtaille=0;
字符串cons、inj、imgrad、analyze;
Console.WriteLine(“客户的信用卡”);
client=(Convert.ToInt32(Console.ReadLine());
如果(客户端>0)
do//un客户端
{
控制台。WriteLine(“请问患者年龄是多少?”);
client=Convert.ToInt32(Console.ReadLine());
如果(客户<12)
{
客户=1;
}
如果(客户>=12 | |客户=19 | |客户65)
{
客户=4;
}
Console.WriteLine(“个人咨询服务?”);
cons=Convert.ToString(Console.ReadLine()).ToLower();
Console.WriteLine(“La personne a t-elle choisit une图像收音机?”);
imgrad=Convert.ToString(Console.ReadLine()).ToLower();
Console.WriteLine(“个人a t-elle Choiset是否分析了德桑?”);
analyze=Convert.ToString(Console.ReadLine()).ToLower();
控制台。WriteLine(“人员a t-elle choisit注射?”);
inj=Convert.ToString(Console.ReadLine()).ToLower();
如果(inj=“oui”)
{
控制台。书写线(“注射的时间(30-50-60)”;
injtaille=Convert.ToInt32(Console.ReadLine());
}
交换机(客户端)
{
案例1:
consprix=25;
imgradprix=55;
分析prix=28;
injprix=0;
打破
案例2:
consprix=32;
imgradprix=65;
分析prix=32;
开关(可插入)
{
案例30:
injprix=13;
打破
案例50:
injprix=(650/30);
打破
案例60:
injprix=(780/30);
打破
违约:
控制台。书写线(“Taille d'inconue.”);
打破
}
打破
案例3:
consprix=40;
imgradprix=70;
分析prix=40;
开关(可插入)
{
案例30:
injprix=13;
打破
案例50:
injprix=(750/30);
打破
案例60:
injprix=(900/30);
打破
违约:
控制台。书写线(“Taille d'inconue.”);
打破
}
打破
案例4:
consprix=30;
imgradprix=60;
分析prix=35;
开关(可插入)
{
案例30:
injprix=13;
打破
案例50:
injprix=(600/30);
打破
案例60:
injprix=(720/30);
打破
违约:
控制台。书写线(“Taille d'inconue.”);
打破
}
打破
}
//翅片开关
如果(imgrad==“非”)
{
imgradprix=0;
}
prixtot += prixclient;