基本算法语句问题 (15 12:1:18)已知华氏温度与摄氏温度的转换公式是:(华氏温度-32)*5/9=摄氏温度编写一个程序,输入一个华氏温度,输出其相应的摄氏温度要运用输入,输出,赋值语句回答
来源:学生作业帮助网 编辑:作业帮 时间:2024/05/13 13:49:21
基本算法语句问题 (15 12:1:18)
已知华氏温度与摄氏温度的转换公式是:(华氏温度-32)*5/9=摄氏温度
编写一个程序,输入一个华氏温度,输出其相应的摄氏温度
要运用输入,输出,赋值语句回答
#include
void main()
{
float Celsius,Fahrenheit;
printf("请输入设施华氏温度\n");
scanf("%d",&Fahrenheit);
Celsius=(Fahrenheit-32)*5/9;
printf("华氏温度%d对应摄氏温度为%d\n",Fahrenheit,Celsius);
}
采用C语言
开始
输入华氏温度t
T(摄氏温度)=(用箭号)(t-32)*5/9
输出T
结束
摄氏温度转换为华氏温度,F为华氏度
华氏温度转换为摄氏温度,C为摄氏度
(1)
Dim C As String
Dim F As String
Private Sub Command1_Click()
C = Text1.Text
If IsNumeric(C) Then
F = 9 * C / 5 + 32
...
全部展开
摄氏温度转换为华氏温度,F为华氏度
华氏温度转换为摄氏温度,C为摄氏度
(1)
Dim C As String
Dim F As String
Private Sub Command1_Click()
C = Text1.Text
If IsNumeric(C) Then
F = 9 * C / 5 + 32
Label1.Caption = F
Else
C = MsgBox("""错误""")
End If
End Sub
Private Sub Command2_Click()
F = Text1.Text
If IsNumeric(F) Then
C = 5 * (F - 32) / 9
Label1.Caption = C
Else
F = MsgBox("""错误""")
End If
End Sub
(2)
Dim C As String
Dim F As String
Private Sub Text1_keypress(KeyAscii As Integer)
If KeyAscii = 13 Then
C = Text1.Text
If IsNumeric(C) = True Then
F = 9 * C / 5 + 32
Label1.Caption = F
Else
C = MsgBox("""错误""")
End If
End If
End Sub
Private Sub Text2_keypress(KeyAscii As Integer)
F = Text2.Text
If KeyAscii = 13 Then
If IsNumeric(F) = True Then
C = 5 * (F - 32) / 9
Label1.Caption = C
Else
F = MsgBox("""错误""")
End If
End If
End Sub
收起
以VB为例 Private Sub Command1_Click() '点击按钮1 t = InputBox("输入华氏温度") '在窗体中 输入 温度并 赋值 给t Print "摄氏温度:" & (t - 32) * 5 / 9 '输出计算结果 End Sub 图为运行界面