今天写代码来了一个异常

/**
* 需求分析:根据输入的天数是否是周六或是周日,
* 并且天气的温度大于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. BugPhobia团队篇章:团队管理与Github源代码管理说明

    0x00:序言 To the searching tags, you may well fall in love withhttp://xueba.nlsde.buaa.edu.cn/ 再见,无忧时光 ...

  2. Daily Scrumming* 2015.12.18(Day 10)

    一.团队scrum meeting照片 二.成员工作总结 姓名 任务ID 迁入记录 江昊 任务1085 https://github.com/buaaclubs-team/temp-front/com ...

  3. 《Linux内核设计与实现》第十八章读书笔记

    1.内核中的bug 内核中的bug表现得不像用户级程序中那么清晰——因为内核.用户以及硬件之间的交互会很微妙: 从隐藏在源代码中的错误到展现在目击者面前的bug,往往是经历一系列连锁反应的事件才可能触 ...

  4. WebAPI实例--第一个API

    今天终于做了第一个任务,学习API之后的第一个实例.销售设置开发API. 第一.层次结构 1.API各层 项目结构主要有五层,分别为API.BizModel.Data.DBModel.Logic. 2 ...

  5. Github上传更新

    通过2天的时间,不停的网上找各种资料,今天下午终于可以登录上github for Windows 客户端了,,, 然后通过一整晚的摸索,也把项目上传到github里. github地址:https:/ ...

  6. 【转】使用screw plus对PHP源码加密

    运行环境 ubuntu 14.04 php 5.6 源码地址 https://github.com/del-xiong/screw-plus http://git.oschina.net/splot/ ...

  7. PhantomJS - Scriptable Headless Browser

    http://phantomjs.org/ PhantomJS is an optimal solution for: Page automation Access webpages and extr ...

  8. Linux 改变文件属性与权限

    常用的修改文件组或文件的命令有三个:chgrp.chown.chmod. 1 chgrp 改变文件所属的用户组 改变一个文件的用户组直接以chgrp来改变即可,这个命令时change group 的简 ...

  9. [转帖]GitHub上整理的一些工具

    GitHub上整理的一些工具   技术站点 Hacker News:非常棒的针对编程的链接聚合网站 Programming reddit:同上 MSDN:微软相关的官方技术集中地,主要是文档类 inf ...

  10. [转自知乎]飞腾国产CPU的部分知识

    1. 作者:常成链接:https://www.zhihu.com/question/48948852/answer/113595308来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...