Scanner sc = new Scanner(System.in)
System.out.println("单位换算,1 fathom= 1.8288 m (1英寻=1.8288米)")
System.out.println("请输入fathom值(1~10)整数:")
int fathomInt = sc.nextInt()
if(fathomInt >= 1 && fathomInt <= 10){
System.out.println(fathomInt+" fathom = "+(fathomInt*1.8288)+"m")
}else{
System.out.println("请正确输入fathom!")
}
sc.close()
}
运行结果
单位换算,1 fathom= 1.8288 m (1英寻=1.8288米)
请输入fathom值(1~10)整数:
2
2 fathom = 3.6576m
这两个看你需要哪一个
public static void main(String[] args) {Scanner sc = new Scanner(System.in)
System.out.println("单位换算,1 fathom= 1.8288 m (1英寻=1.8288米)")
System.out.println("请输入fathom值(1~10)整数:")
int fathomInt = sc.nextInt()
if(fathomInt >= 1 && fathomInt <= 10){
System.out.println("Fathom Meter")
for(int i = 0 i < fathomInt i++){
System.out.println((i+1)+" "+((i+1)*1.8288))
}
//System.out.println(fathomInt+" fathom = "+(fathomInt*1.8288)+"m")
}else{
System.out.println("请正确输入fathom!")
}
sc.close()
}
运行结果
单位换算,1 fathom= 1.8288 m (1英寻=1.8288米)
请输入fathom值(1~10)整数:
6
Fathom Meter
1 1.8288
2 3.6576
3 5.4864
4 7.3152
5 9.144
6 10.9728
1、一般用公式的方法来进行处理。2、“寸”分为英制和市制;
3、英制换算:在C2单元格输入:=CONVERT(A2,"m","in")
4、A2单元格输入1000,C2单元格自动显示;不需要加单位了,公式中已包含;
5、市制换算:在C2单元格输入:=A2*30&"寸"
另外,可以根据的工作需要,编制小的vba程序,这样可以通过执行程序来很方便地完成要做的工作。
#include<stdio.h>#include<iostream.h>
int main()
{
double num
double n
double m
while(true)
{
cout<<"请选择要输入的单位:1、毫米;2、厘米;3、米;4、千米" <<endl
cin >> num
cout << "请输入单位长度" <<endl
cin >> m
if(num == 1)
{
cout << "请选择要转换的单位:1、厘米;2、米;3、千米" <<endl
cin >> n
if(n == 1)
{
cout<<"毫米转换成厘米结果为:"<<m<<"mm="<<m/100<<"cm"<<endl
} else if(n == 2) {
cout<<"毫米转换成米结果为:"<<m<<"mm="<<m/1000<<"m"<<endl
} else if(n == 3) {
cout<<"毫米转换成千米结果为:"<<m<<"mm="<<m/1000000<<"km"<<endl
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
} else if(num == 2) {
cout << "请选择要转换的单位:1、毫米;2、米;3、千米" <<endl
cin >> n
if(n == 1)
{
cout<<"厘米转换成毫米结果为:"<<m<<"cm="<<m*100<<"mm"<<endl
} else if(n == 2) {
cout<<"厘米转换成米结果为:"<<m<<"cm="<<m/10<<"m"<<endl
} else if(n == 3) {
cout<<"厘米转换成千米结果为:"<<m<<"cm="<<m/10000<<"km"<<endl
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
} else if(num == 3) {
cout << "请选择要转换的单位:1、毫米;2、厘米;3、千米" <<endl
cin >> n
if(n == 1)
{
cout<<"米转换成毫米结果为:"<<m<<"m="<<m*1000<<"mm"<<endl
} else if(n == 2) {
cout<<"米转换成厘米结果为:"<<m<<"m="<<m*10<<"cm"<<endl
} else if(n == 3) {
cout<<"米转换成千米结果为:"<<m<<"m="<<m/1000<<"km"<<endl
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
} else if(num == 4) {
cout << "请选择要转换的单位:1、毫米;2、厘米;3、米" <<endl
cin >> n
if(n == 1)
{
cout<<"千米转换成毫米结果为:"<<m<<"km="<<m*1000*1000<<"mm"<<endl
} else if(n == 2) {
cout<<"千米转换成厘米结果为:"<<m<<"km="<<m*10*1000<<"cm"<<endl
} else if(n == 3) {
cout<<"千米转换成米结果为:"<<m<<"km="<<m*1000<<"m"<<endl
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
}
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)