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 ...
随机推荐
- hots团队项目终审报告
一.团队成员: 徐钧鸿: 1994年1月19日生人,摩羯座最后一天.所以有摩羯的强迫症和水瓶古怪的性格 暂且算队长吧…… 高中的时候因为兴趣学了竞赛,于是就入坑了,于是就来北航学计算机了 兴趣面很广, ...
- 素数问题练习_HDOJ1262
HDOJ1262_寻找素数对 和上一篇博客一样的解法,将10000以内的所有素数求出即可解题. #include<stdio.h> #include<stdlib.h> #in ...
- PAT 1037 在霍格沃茨找零钱
https://pintia.cn/problem-sets/994805260223102976/problems/994805284923359232 如果你是哈利·波特迷,你会知道魔法世界有它自 ...
- Spring Cloud的Zuul的使用问题
Zuul Client 放在移动App中,Zuul Server可以做集群. Zuul Client放在jar包吗?ios怎么办? Zuul与Spring Security配合使用,与Shiro做集成 ...
- MYSQL InnoDB Cluster
https://dev.mysql.com/doc/refman/5.7/en/group-replication.html GroupReplication的原理 https://dev.mysql ...
- 自己站点的nginx 配置信息
user www www; worker_processes auto; error_log /home/wwwlogs/nginx_error.log crit; pid /usr/local/ng ...
- [日常工作] Linux与Windows的连接访问以及数据共享等方法 vncserver smb xshell xftp winscp mount等
日常办公机器是用 windows, 但是越来越多的测试和工作需求需要使用linux. 这里以最常用的系统centos为例进行说明 1. 远程连接 ssh的方式 建议使用xmange 系列的 xshel ...
- 梯度、散度、旋度、Jacobian、Hessian、Laplacian 的关系图
转自松鼠的窝 一.入门
- 如何利用Hadoop存储小文件
**************************************************************************************************** ...
- 跪求delphi 中的bitbutton 中的bmp图标
C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\Images\GlyFX