/*3-6.程序员;龚猛*/
 1 package zhenshu;
import java.util.Scanner;
public class text { public static void main(String[] args) {
Scanner input = new Scanner(System.in); System.out.print("Enter an integer:");
int number = input.nextInt(); if (number % 2 == 0 && number % 3 == 0)
System.out.println(number + "is divisible by 2 and 3."); if (number % 2 == 0 || number % 3 == 0)
System.out.println(number + "is divisible by 2 and 3."); if (number % 2 == 0 ^ number % 3 == 0)
System.out.println(number + "is divisible by 2 and 3. but not both."); } }
 /*3-7*/
package zhenshu;
import java.util.Scanner;
public class Year { public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a year:");
int year = input.nextInt(); boolean isLeapYear =
(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); System.out.println(year + "is a leap year?" + isLeapYear);
} }
 /*3-8*/
package zhenshu;
import java.util.Scanner;
public class lottery { public static void main(String[] args) {
int lottery = (int)(Math.random() * 100); Scanner input = new Scanner(System.in);
System.out.print("Enter your lottery pick (two digits):");
int guess = input.nextInt(); int lotteryDigit1 = lottery / 10;
int lotteryDigit2 = lottery % 10; int guessDigit1 = guess / 10;
int guessDigit2 = guess % 10; System.out.println("The lottery number is" + lottery); if(guess == lottery)
System.out.println("Exact match: you win $10,000"); else if(guessDigit2 == lotteryDigit1 && guessDigit2 == lotteryDigit2 )
System.out.println("Match all digits: you win $3,000");
else if(guessDigit1 == lotteryDigit1 || guessDigit1 == lotteryDigit2
||guessDigit2 == lotteryDigit1 || guessDigit2 == lotteryDigit2)
System.out.println("Match all digits: you win $1,000");
else
System.out.println("Sorry,no match"); } }
 /*3-9*/
package zhenshu; import java.util.Scanner; public class ChinaYear { public static void main(String[] args) {
Scanner input = new Scanner(System.in); System.out.print("Enter a year:");
int year = input.nextInt(); switch (year % 12){
case 0: System.out.println("monkey"); break;
case 1: System.out.println("rooster"); break;
case 2: System.out.println("dog"); break;
case 3: System.out.println("pig"); break;
case 4: System.out.println("rat"); break;
case 5: System.out.println("ox"); break;
case 6: System.out.println("tiger"); break;
case 7: System.out.println("rabbit"); break;
case 8: System.out.println("dragon"); break;
case 9: System.out.println("snake"); break;
case 10: System.out.println("horse"); break;
case 11: System.out.println("sheep"); break;
}
} }

Java作业五(2017-10-15)的更多相关文章

  1. 结束《Java编程思想》(Thinking in Java)自学的读后感(2017.10.15)

    首先划重点:这是一本Java的入门书. 自学前需要的条件:已经具备基本的计算机基础. 1)已经对一种编程语言比较熟悉: 2)有过四年计算机专业学习,或者三年以上的软件开发经验, 自学的方法: 1)完全 ...

  2. 2017.10.15 解析Java中抽象类和接口的区别

    (1)在Java语言中,abstract class 和interface 是支持抽象类定义的两种机制. 正是由于这两种机制的存在,才赋予了Java强大的 面向对象能力.abstract class和 ...

  3. C语言程序设计第一次作业(2017.10.10完成)

    一:程序框图以及正确运行结果: (1)给出圆半径,得出圆面积: ①程序框图如下: ②测试图如下: 经过测试 ,输入半径2能得出正确结果.多次测试,输入不同值,均得出正确结果,证明稳定性. ③实验分析: ...

  4. Java作业五

    1.编程生成10个1~100之间的随机数,并统计每个数出现的概率. 这个博文里面又random的详细解释:https://www.cnblogs.com/ningvsban/p/3590722.htm ...

  5. 2017/10 冲刺NOIP集训记录:暁の水平线に胜利を刻むのです!

    前几次集训都没有记录每天的点滴……感觉缺失了很多反思的机会. 这次就从今天开始吧!不能懈怠,稳步前进! 2017/10/1 今天上午进行了集训的第一次考试…… 但是这次考试似乎是近几次我考得最渣的一次 ...

  6. Java第五次作业--面向对象高级特性(抽象类与接口)

    Java第五次作业--面向对象高级特性(抽象类与接口) (一)学习总结 1.在上周完成的思维导图基础上,补充本周的学习内容,对Java面向对象编程的知识点做一个全面的总结. 2.汽车租赁公司,出租汽车 ...

  7. 2017.10.12 Java的计数器的开发

    //我们用一个合成的applet/application来简单显示出一个计数器的结果/** * Created by qichunlin on 2017/10/12. */ /*简单的计数器*/ im ...

  8. 2017.10.10 java中的继承与多态(重载与重写的区别)

    1. 类的继承 继承是面向对象编程技术的主要特征之一,也是实现软件复用的重要手段,使用继承特性子类(subclass) 可以继承父类(superclass)中private方法和属性,继承的目的是使程 ...

  9. 第五次Java作业

    作业一: 文件显示列表框. 增加了下拉式组合框,text区域设置颜色为红色. import javax.swing.*; import java.awt.*; import java.io.File; ...

随机推荐

  1. newSoft

    Email:kefu007@vip.qq.com CADソフト Siemens PLM NX 1847 (64ビット) 日本語版 KeyCreator Ver.15.5 (64ビット)日本語版 MYP ...

  2. bzoj 2599

    还是点对之间的问题,果断上点分治 同样,把一条路径拆分成经过根节点的两条路径,对不经过根节点的路径递归处理 然后,我们逐个枚举根节点的子树,计算出子树中某一点到根节点的距离,然后在之前已经处理过的点中 ...

  3. VMware vSphere 组件和功能

    https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vsphere.introduction.doc_50%2FGUID- ...

  4. js 如何将dom转换为 图片(base64)

    1.引入js <script src="https://cdn.bootcss.com/html2canvas/0.4.1/html2canvas.js"></s ...

  5. TPshop之邮箱注册配置教程--附加常见问题集合

    ​ 准备:企业邮箱(开启POP/SMTP功能) 一.步骤教程: 1.登录企业邮箱(QQ邮箱示例) QQ邮箱 POP3:pop.qq.com SMTP:smtp.qq.com SMTP端口号:25 邮箱 ...

  6. [原创]SecureCRT终端软件连接VMware Workstation Pro虚拟机

    Step1:检查主机的桥接有没有禁用 Step2:进入Ubuntu系统,进入到Ubuntu下,先查看Ubuntu虚拟机的IP配置,打开终端(Ctrl+Alt+T),通过ifconfig命令查看,可以看 ...

  7. React:受控组件与非受控组件混用实战 - 译文

    原文链接:React: hybrid controlled components in action 受控组件 非受控组件 混用受控组件和非受控组件 原则一 原则二 原则三 原则四 实施方案 总结 F ...

  8. C# Conversion Keywords

    主要是解决类与其他不同数据类型的转换 类于类的显式转换: explicit  public static explicit operator B(A a) { return new B(){a.... ...

  9. java文件过滤器的使用

    前言: java.io.FileFilter(过滤器接口)boolean accept(File pathname) File类提供了如下方法使用过滤器:public File[] listFiles ...

  10. 课堂小记---JavaScript(4)

    day11 1.正则表达式 去掉首尾的空格或者其他字符 replace方法可传入函数可分组. 以下为分组 基础正则表达式语法: /** * 正则表达式是一个对象类型 */ // 匹配字符串中的che ...