今天写代码来了一个异常

/**
* 需求分析:根据输入的天数是否是周六或是周日,
* 并且天气的温度大于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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Exception in thread "main" java.util.ConcurrentModificationException解决方案

    我想判断一个集合里面有没有"world"这个元素,如果有,我就添加一个"javaee"元素, 当时的做法是: public class ListIterator ...

  5. Exception in thread "main" java.util.ConcurrentModificationException

    package test; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public c ...

  6. 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 ...

  7. 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 ...

  8. unit测试出现异常:Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util

    在进行单元测试时,测试出现异常 Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform ...

  9. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/util/POILogFactory

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/util/POILogFacto ...

随机推荐

  1. 《Linux内核设计与实现》第4章读书整理

    第四章   进程调度 4.1多任务 无论在单处理器或者多处理机器上,多任务操作系统都能使多个进程处于堵塞或者睡眠状态. 非抢占式多任务:除非进程自己主动停止运行,否则它会一直执行. 抢占式多任务:进程 ...

  2. (Alpha)Let's-版本发布说明

    我们的Let’s APP发布了! (下载地址在“下载与安装”部分) Alpha版本功能 Alpha版本是我们发布的第一个版本,所以仅实现了活动实体和用户实体之间的基础联系功能. 基本功能 登录和注册 ...

  3. 照片 GPS 信息查询

    照片 GPS 信息查询 经纬度查询 https://jingweidu.51240.com/ // 30.27832833333333, 120.01914111111111 30 + 16/60 + ...

  4. JavaScript从入门到精通

    第一(基本语法) if(condition1){ expression1; }else if(condition2){ expression2; }else{ expression3; } switc ...

  5. ubuntu iftop工具安装和参数

    安装iftop有很多依赖关系: sudo apt-get install flex bison wget http://www.tcpdump.org/release/libpcap-1.5.3.ta ...

  6. delphi property read writer 如何使用

    type TMyClass = class(TObject) private FMyName: string; FMyAge: Integer; procedure SetAge(age: Integ ...

  7. Java ThreadLocal 理解

    ThreadLocal 概念: ThreadLocal不是用来解决对象共享访问的问题,而主要是提供了保存对象的方法和避免参数传递的方便的对象访问方式. ThreadLocal并不是一个Thread,而 ...

  8. selenium之测试卫星资料页面操作(元素遍历)

    # 测试气象卫星资料页面功能 # author:gongxr # date:2017-07-24 import random, time from selenium import webdriver ...

  9. double转换为二进制

    arctan 在verilog 里是1qn或2qn格式,所以要把浮点数转换成1qn格式 1.dec2bin(十进制整数变为二进制) Convert decimal to binary number i ...

  10. 10 月 30 日新款 Mac mini 有望与新款 iPad Pro 一起发布

    苹果最新款的 Mac mini 是在 2014 年 10 月推出的版本,到现在已经过了 4 年.分析师郭明錤和彭博社的 Mark Gurman 都表示苹果会在今年晚些时候发布新款 Mac mini. ...