C#温度转换:编写一个控制台程序

C#温度转换:编写一个控制台程序,第1张

class tempera{

public tempera() : this(0){}

public tempera(int cel) {thiscel = cel;}

private int cel;

public Cels {

get{return cel;} set{thiscel=value;}

}

public int change() { return thiscel 9 / 5 + 32;}

static void main(string[] args){

ConsoleWriteLine("请输入摄氏温度值:")

ConsoleWriteLine("转换为华氏温度值为{0}度",

new Cels(ConvertToint32(ConsoleReadLine()))change()

ConsoleReadkey();

}

}

你好!!

请看代码,:

#include<stdioh>

int main()

{

int x;

float a,s;

printf("请选择转换的类型:\n 华氏转摄氏(1)\n 摄氏转华氏(2)\n");

scanf("%d",&x);

switch(x)

{

case 1:

printf("华氏温度:");

scanf("%f",&a);

s=(a-32)/18;

printf("摄氏温度:%22f\n",s);

break;

case 2:

printf("摄氏温度:");

scanf("%f",&a);

s=a18+32;

printf("华氏温度:%22f\n",s);

break;

}

return 0;

} 你好!!另一个接法,合乎你的题目要求:

#include<stdioh>

int main()

{

int x;

float a,s;

int ii=0;

for(ii=0;ii<3;ii++)

{

printf("请选择转换的类型:\n 华氏转摄氏(1)\n 摄氏转华氏(2)\n");

scanf("%d",&x);

switch(x)

{

case 1:

printf("华氏温度:");

scanf("%f",&a);

s=(a-32)/18;

printf("摄氏温度:%22f\n",s);

break;

case 2:

printf("摄氏温度:");

scanf("%f",&a);

s=a18+32;

printf("华氏温度:%22f\n",s);

break;

}

}

return 0;

}

#include<iostream>

using namespace std;

void main()

{

double f,c;

cout<<"请输入华氏温度:";

cin>>f;

c=(f-320)50/90;

cout<<“摄氏温度为:”<<c;

}

void main(){folat ht,st;int i;print("请选择温度转换的方式\n1转换成摄氏温度\n2转换成华氏温度");if(i==1){print("请输入一个摄氏温度:");scanf("%f",st);//添加计算公式,假设结果为htprint("转换成华氏温度为:%f",ht);}else if(i==2){print("请输入一个华氏温度:");scanf("%f",ht);//添加计算公式,假设结果为stprint("转换成华氏温度为:%f",st);}else{print("输入错误!");}}

以上就是关于C#温度转换:编写一个控制台程序全部的内容,包括:C#温度转换:编写一个控制台程序、c语言华氏摄氏温度转换、c++程序 编写一个函数把华氏温度转换为摄氏温度,转换格式如下: c=(f-32)*5/9等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/10120371.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存