zoukankan      html  css  js  c++  java
  • 2017.12.1T19_B2_2zuoye

    package com.whxiong.work01;

    import java.util.Scanner;

    public class Calculator {
     Scanner input = new Scanner(System.in);
     public void show() {  
      char Calculator;
      double num = 0;
      double num1 = 0;
      System.out.println("请输入第一个整数:");
      do {
       if (input.hasNextInt() == false) {
        System.out.println("输入错误!");
        break;
       }
       if (input.hasNextInt() == true)
        ;
       {
        num = input.nextInt();
       }
       System.out.println("请输入第二个整数:");
       if (input.hasNextInt() == false) {
        System.out.println("输入错误!");
        break;
       }
       if (input.hasNextInt() == true) {
        num1 = input.nextInt();
       }
       System.out.println("请输入运算符号:+ - * /");
       Calculator = input.next().charAt(0);
       switch (Calculator) {
       case '+':
        System.out.println(num + "+" + num1 + "=" + (num + num1));
        break;
       case '-':
        System.out.println(num + "-" + num1 + "=" + (num - num1));
        break;
       case '*':
        System.out.println(num + "*" + num1 + "=" + (num * num1));
        break;
       case '/':
        System.out.println(num + "/" + num1 + "=" + (num / num1));
        break;
       }
       break;
      } while (input.hasNextInt() == false);
     *****************************************************

    package com.whxiong.work01;

    public class CurrentTime {
        String year;
           String mooth;
           String date;
           String hour;//小时
           String minutes;//分钟
           String second;//秒     
    public void show1(){
     System.out.println("当前时间是:"+(year+mooth+date+hour+minutes+second));
    }
          ***********************************************************

    package com.whxiong.work01;
    import java.util.*;
    public class Hero {
     Scanner input=new Scanner(System.in);
      String heroName;
      double heroLife;
      String monsterName;//monster》》》》怪物
      double monsterLife;//怪物生命
      String monsterType;//怪物类型
      String weaponsName;//weapons》》》》武器
      double weaponsDamage;//damage》》》》攻击力,武器攻击力
     public void show2() {
      System.out.println("输入英雄姓名:");
       heroName=input.next();
       System.out.println("输入英雄生命值:");
       heroLife=input.nextDouble();
      System.out.println("输入怪物名字:");
       monsterName=input.next();
      System.out.println("输入怪物生命值:");
       monsterLife=input.nextDouble();
      System.out.println("输入怪物类型:");
       monsterType=input.next();
      System.out.println("输入武器名:");
       weaponsName=input.next();
      System.out.println("输入武器攻击力:");
       weaponsDamage=input.nextDouble();
      System.out.println("我是英雄,我的基本信息如下:");
      System.out.println("姓名:"+heroName+",生命值:"+heroLife);
      System.out.println("我是武器,我的基本信息如下:");
      System.out.println("武器名:"+weaponsName+",攻击力:"+weaponsDamage);
      System.out.println("我是怪物,我的基本信息如下:");
      System.out.println("姓名:"+monsterName+",生命值:"+monsterLife+",类型:"+monsterType); 
     } 
    }******************************************************

    package com.whxiong.work01;

    public class Work01 {

     /**
      * @param args
      */
     public static void main(String[] args) {
      System.out.println("第二题");
      System.out.println("******************************");
      Calculator calculator = new Calculator();
      calculator.show();
      
      System.out.println(" ");
      System.out.println("第三题");
      System.out.println("******************************");
      CurrentTime currentTime = new CurrentTime();
      currentTime.year = "2015年";
      currentTime.mooth = "5月";
      currentTime.date = "12日";
      currentTime.hour = "10点";
      currentTime.minutes = "11分";
      currentTime.second = "00秒";
      currentTime.show1();
      
      System.out.println(" ");
      System.out.println("第六题");
      System.out.println("******************************");
      System.out.println(" ");
      Hero hero = new Hero();
      hero.show2();
      

  • 相关阅读:
    关于 setColorFilter 和 PorterDuff.Mode
    下拉刷新 SwipRefreshLayout
    from athletelist import AthleteList出现红色下滑波浪线警告
    IndentationError: unindent does not match any outer indentation level
    定制数据对象2
    定制数据对象
    数据处理02
    数据处理
    python 工具箱
    嵌套列表的格式打印
  • 原文地址:https://www.cnblogs.com/xiaoxiao1016/p/7991535.html
Copyright © 2011-2022 走看看