Exception in thread "main" java.util.InputMismatchException
今天写代码来了一个异常
/**
* 需求分析:根据输入的天数是否是周六或是周日,
* 并且天气的温度大于28摄氏度,则外出游泳,否则钓鱼
* @author chenyanlong
* 日期:2017/10/14
*/
package com.hp.test03; import java.util.Scanner; public class HS_JudgeOutgoing { public static void main(String[] args) {
// TODO Auto-generated method stub
int day;
double temperature;
//double temperature = 0.0; System.out.println("请输入今天星期几,如果周n ,请输入”n“,eg:7");
Scanner input=new Scanner(System.in);
day=input.nextInt(); if(day==6||day==7){
//温度判断
System.out.println("请输入今天的温度,eg:29.8");
Scanner input2=new Scanner(System.in);
temperature=input2.nextInt();
if(temperature>25){
System.out.println("今天适合——游泳");
}else{
System.out.println("今天适合——钓鱼");
}
}else{
System.out.println("你还是老实写代码!!");
} }
}
如果temperature输入的为整数,就没有异常,一旦输入了小数就会出现异常

解决方法:

Exception in thread "main" java.util.InputMismatchException的更多相关文章
- Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 [ ^
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character clas ...
- Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 解决方法: 要对切割字符进行转义\\
使用str.split("[",15)时,出现Exception in thread "main" java.util.regex.PatternSyntaxE ...
- Exception in thread "main" java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for topic_test_1219-2: 30010 ms has passed since batch creatio
代码如下 public static void producer1() throws ExecutionException, InterruptedException { Properties pro ...
- Exception in thread "main" java.util.ConcurrentModificationException解决方案
我想判断一个集合里面有没有"world"这个元素,如果有,我就添加一个"javaee"元素, 当时的做法是: public class ListIterator ...
- Exception in thread "main" java.util.ConcurrentModificationException
package test; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public c ...
- WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Exception in thread "main" java.io.IOException: No FileSystem for sc F
1.执行脚本程序报如下所示的错误: [hadoop@slaver1 script_hadoop]$ hadoop jar web_click_mr_hive.jar com.bie.hive.mr.C ...
- Exception in thread "main" java.lang.StackOverflowError at java.util.ArrayList$SubList.rangeCheckForAdd(Unknown Source)
Exception in thread "main" java.lang.StackOverflowError at java.util.ArrayList$SubList.ran ...
- unit测试出现异常:Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util
在进行单元测试时,测试出现异常 Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform ...
- Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/util/POILogFactory
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/util/POILogFacto ...
随机推荐
- git使用(2)
1.远程仓库 a SSHKEY 第1步:创建SSH Key.在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到 ...
- div+css实现圆形div以及带箭头提示框效果
.img{ width:90px; height:90px; border-radius:45px; margin:0 40%; border:solid rgb(100,100,100) 1px;& ...
- Java awt项目开发
通过Java awt 界面上的知识编写的扫雷游戏 代码中有详细的注解 package com.langsin.saolei; import java.awt.Color;import java.awt ...
- 01springboot快速入门
SpringBoot快速入门 springboot的宗旨是习惯大于配置,所以spring里面大量使用了默认的配置来简化spring的配置.spring Boot的主要优点: 为所有Spring开发者更 ...
- 【转】STM32 独立看门狗简介
STM32 的独立看门狗由内部专门的 40Khz 低速时钟驱动,即使主时钟发生故障,它也仍然有效. 看门狗的原理:单片机系统在外界的干扰下会出现程序跑飞的现象导致出现死循环,看门狗电路就是为了避免这种 ...
- Centos wget命令 not found解决方法
如果已经有了yun源,则可通过yun源命令来安装wget. 如下所示: 2.yum安装yum -y install wget 即可安装:
- MYSQL InnoDB Cluster
https://dev.mysql.com/doc/refman/5.7/en/group-replication.html GroupReplication的原理 https://dev.mysql ...
- Windows 安装 docker 以及1709的简单使用
PS C:\> Install-Module -Name DockerMsftProvider -Repository PSGallery -Force PS C:\> Install-P ...
- SQL Data Compare 对比 SQLserver数据
1. 下载redgate的工具 https://www.red-gate.com/dynamic/products/sql-development/sql-compare/download 2. 输入 ...
- Jquery ajax load(),get(),post()
//load()用来加载html文档中的代码片段,添加到指定元素内部 //如果只加部分选定的元素可以.load("url 选择器") <!DOCTYPE html>&l ...