如何用计算机克数和斤换算,质量(重量)单位换算计算器

option{title:"质量(重量)单位换算计算器";comment:"可进行各种质量(重量)单位制的换算。\n支持以下单位制:\n吨(t)、公斤(kg)、克(g)、毫克(mg)、市斤、担、两、钱、金衡磅(lb t)、金衡盎司(oz t)、英钱(dwt)、金衡格令、(英制)长吨、(美制)短吨、英担(cwt)、美担(cwt)、英石、磅(lb)、盎司(oz)、打兰(dr)、格令、克拉(carat)、分(point)";}

input{iv:"换算前数值";iu:"换算前单位制";ou:"换算后单位制";}

output{ri:hide;ro:hide;ov:"换算后数值";}

view{

iu:"","吨(t)","公斤(kg)","克(g)","毫克(mg)","市斤","担","两","钱","金衡磅(lb t)","金衡盎司(oz t)","英钱(dwt)","金衡格令","(英制)长吨","(美制)短吨","英担(cwt)","美担(cwt)","英石","磅(lb)","盎司(oz)","打兰(dr)","格令","克拉(carat)","分(point)";

ou:"","吨(t)","公斤(kg)","克(g)","毫克(mg)","市斤","担","两","钱","金衡磅(lb t)","金衡盎司(oz t)","英钱(dwt)","金衡格令","(英制)长吨","(美制)短吨","英担(cwt)","美担(cwt)","英石","磅(lb)","盎司(oz)","打兰(dr)","格令","克拉(carat)","分(point)";}

validate{alert:[iu==0,"请选择换算前单位制"][ou==0,"请选择换算后单位制"];}

ri=when(iu-1,0,0.001)

+when(iu-2,0,1)

+when(iu-3,0,1000)

+when(iu-4,0,1000000)

+when(iu-5,0,2)

+when(iu-6,0,0.02)

+when(iu-7,0,20)

+when(iu-8,0,200)

+when(iu-9,0,2.6792288807189983)

+when(iu-10,0,32.15074656862797)

+when(iu-11,0,643.0149313725595)

+when(iu-12,0,15432.358352941428)

+when(iu-13,0,0.0009842065276110606)

+when(iu-14,0,0.001102311310924388)

+when(iu-15,0,0.01968413055222121)

+when(iu-16,0,0.022046226218487758)

+when(iu-17,0,0.1574730444177697)

+when(iu-18,0,2.2046226218487757)

+when(iu-19,0,35.27396194958041)

+when(iu-20,0,564.3833911932866)

+when(iu-21,0,15432.358352941428)

+when(iu-22,0,5000)

+when(iu-23,0,500000);

ro=when(ou-1,0,0.001)

+when(ou-2,0,1)

+when(ou-3,0,1000)

+when(ou-4,0,1000000)

+when(ou-5,0,2)

+when(ou-6,0,0.02)

+when(ou-7,0,20)

+when(ou-8,0,200)

+when(ou-9,0,2.6792288807189983)

+when(ou-10,0,32.15074656862797)

+when(ou-11,0,643.0149313725595)

+when(ou-12,0,15432.358352941428)

+when(ou-13,0,0.0009842065276110606)

+when(ou-14,0,0.001102311310924388)

+when(ou-15,0,0.01968413055222121)

+when(ou-16,0,0.022046226218487758)

+when(ou-17,0,0.1574730444177697)

+when(ou-18,0,2.2046226218487757)

+when(ou-19,0,35.27396194958041)

+when(ou-20,0,564.3833911932866)

+when(ou-21,0,15432.358352941428)

+when(ou-22,0,5000)

+when(ou-23,0,500000);

ov=iv*ro/ri;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以为您提供一个简单的Java代码实现度量衡单位换算计算器。以下是示例代码: ```java import java.util.Scanner; public class UnitConverter { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("请选择要转换的单位类型:"); System.out.println("1. 长度"); System.out.println("2. 重量"); System.out.println("3. 温度"); int choice = input.nextInt(); switch(choice) { case 1: System.out.println("请选择要转换的长度单位:"); System.out.println("1. 米"); System.out.println("2. 厘米"); System.out.println("3. 英寸"); int lengthChoice = input.nextInt(); System.out.print("请输入要转换的长度值:"); double lengthValue = input.nextDouble(); switch(lengthChoice) { case 1: System.out.println("转换成厘米为:" + lengthValue * 100); System.out.println("转换成英寸为:" + lengthValue * 39.37); break; case 2: System.out.println("转换成米为:" + lengthValue / 100); System.out.println("转换成英寸为:" + lengthValue / 2.54); break; case 3: System.out.println("转换成米为:" + lengthValue / 39.37); System.out.println("转换成厘米为:" + lengthValue * 2.54); break; default: System.out.println("无效的单位选择!"); } break; case 2: System.out.println("请选择要转换的重量单位:"); System.out.println("1. 克"); System.out.println("2. 千克"); System.out.println("3. 磅"); int weightChoice = input.nextInt(); System.out.print("请输入要转换的重量值:"); double weightValue = input.nextDouble(); switch(weightChoice) { case 1: System.out.println("转换成千克为:" + weightValue / 1000); System.out.println("转换成磅为:" + weightValue * 0.00220462); break; case 2: System.out.println("转换成克为:" + weightValue * 1000); System.out.println("转换成磅为:" + weightValue * 2.20462); break; case 3: System.out.println("转换成克为:" + weightValue * 453.592); System.out.println("转换成千克为:" + weightValue * 0.453592); break; default: System.out.println("无效的单位选择!"); } break; case 3: System.out.println("请选择要转换的温度单位:"); System.out.println("1. 摄氏度"); System.out.println("2. 华氏度"); int temperatureChoice = input.nextInt(); System.out.print("请输入要转换的温度值:"); double temperatureValue = input.nextDouble(); switch(temperatureChoice) { case 1: System.out.println("转换成华氏度为:" + temperatureValue * 1.8 + 32); break; case 2: System.out.println("转换成摄氏度为:" + (temperatureValue - 32) / 1.8); break; default: System.out.println("无效的单位选择!"); } break; default: System.out.println("无效的单位类型!"); } input.close(); } } ``` 该代码实现了一个简单的度量衡单位换算计算器,支持长度、重量和温度三种单位类型的转换。用户可以通过命令行界面选择要转换的单位类型和具体的单位,然后输入要转换的数值,程序会输出转换后的结果。请注意,该代码仅供参考,实际使用时可能需要根据具体需求进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值