package temperature.convert;

import java.util.Scanner;

public class Converter {

    public static void main(String[] args) {
// TODO 自动生成的方法存根
int flag; //进行功能选择
int centigrade; //用于输入摄氏温度
int fahrenheit; //用于输入华氏温度
double centigrade1; //用于保存计算后的摄氏温度
double fahrenheit1; //用于保存计算工后的华氏温度 System.out.println("摄氏温度与华氏温度的相互转换:1-----摄氏温度转换成华氏温度");
System.out.println(" 2-----华氏温度转换成摄氏温度"); /*
以下代码用于接收输入的一个整数,用于进行转换功能的选择
*/
System.out.print("请选择选项:");
Scanner input1 = new Scanner(System.in);
flag = input1.nextInt();
switch(flag)
{
case 1:
System.out.print("请输入摄氏温度:");
Scanner intput2 = new Scanner(System.in);
centigrade = intput2.nextInt();
fahrenheit1 = 9.0 * centigrade / 5.0 + 32;
System.out.println("转换后的华氏温度是:" + fahrenheit1);
break;
case 2:
System.out.print("请输入华氏温度:");
Scanner intput3 = new Scanner(System.in);
fahrenheit = intput3.nextInt();
centigrade1 = 5.0 / 9.0 * (fahrenheit - 32);
System.out.println("转换后的摄氏温度是:" + centigrade1);
break;
default:
System.out.println("输入的字符有误,程序结束!");
break;
}
}
}

System.out.print("")      输出

System.out.println("")    输出一行

System.in                     输入

Scanner input1 = new Scanner(System.in)     接受一个输入的值

input1.nextInt()    说明输入的只能是数字

最新文章

  1. GJM: 设计模式 - 观察者模式
  2. ViewPager自动轮播
  3. __definedGetter\Setter__的一些想法
  4. [C++] C/C++ 取整函数ceil(),floor()
  5. lintcode:数字三角形
  6. 系统设计 - IOS 程序插件及功能动态更新思路
  7. The Greate Wall 相关网络知识(一)域名劫持
  8. JDWP
  9. svn to git
  10. OO第四次博客作业
  11. [leetcode]332. Reconstruct Itinerary
  12. 使用css时的一些技巧及注意事项
  13. android recovery 升级之USB设备挂载
  14. JDK 1.8源码阅读 ArrayList
  15. java调用.net的webservice
  16. memcached centos启动笔记
  17. Prim算法和Kruskal算法求最小生成树
  18. [arc081F]Flip and Rectangles-[黑白染色]
  19. 170725、Kafka原理与技术
  20. MonoSingleton——Unity中的单例模式

热门文章

  1. mysql show status
  2. sql索引实例
  3. 关于token的杂记
  4. Windows Internals学习笔记(六)Windows关键系统组件
  5. jquery引用方法时传递参数
  6. Gitblit Go
  7. excel模版从xp复制到win7系统后出现错误 运行时错误 '429' ActiveX 部件不能创建对象
  8. 转:C++中的单例模式
  9. 转!!mybatis在xml文件中处理大于号小于号的方法
  10. 面试题2:BAT及各大互联网公司2014前端笔试面试题:HTML/CSS篇