java输入一个整数对应英文星期,如何写Java程序来接受用户输入的一个1-12之间的整数,用switch语句输出对应月份的天数?...

www.mh456.com防采集。

import java.util.Scanner;public class QuestionOne {private static boolean start;public static void main(String[] args) {e69da5e6ba907a686964616f31333365636561boolean really=true;Scanner sc=new Scanner(System.in);while(really=true){boolean temp=true;int num=0;start:while(temp==true){System.out.print("请输入要查询的月份:");num=sc.nextInt();if(num>12 ||num<1){System.out.println("你输入的月份错误,请重新输入");continue;}temp=false;}int dayOfMonth = 0;switch (num) {case 1:dayOfMonth=31;break;case 2:dayOfMonth=28;break;case 3:dayOfMonth=31;break;case 4:dayOfMonth=30;break;case 5:dayOfMonth=31;break;case 6:dayOfMonth=30;break;case 7:dayOfMonth=31;break;case 8:dayOfMonth=31;break;case 9:dayOfMonth=30;break;case 10:dayOfMonth=31;break;case 11:dayOfMonth=30;break;case 12:dayOfMonth=31;break;default:break;}if(num==2){System.out.println("'"+num+"'月对应的天数是:'"+dayOfMonth+"'或者29"); }else{System.out.println("'"+num+"'月对应的天数是:'"+dayOfMonth+"'");}System.out.println("C为继续,其余任意键退出!");String t=sc.next();if(t!="c"){really=false;}}}}//(楼主如果需要判断闰年的话给发个悄悄话,这是为2月准备的)

public static void main(String[]args){ Scanner s=new Scanner(System.in);System.out.println(\"input number:\");Integer sum=1;while(true){ Integer i=s.nextInt();if(i|i>10){ System.err.

1563531w2u160-2a04.jpg

import java.util.Scanner;class Switch{public void contains(int temp){7a64e78988e69d8331333365636561switch(temp){case 1:{System.out.println(""+temp+"月为31天!!!");break;}case 2:{System.out.println(""+temp+"月为28天!!!");break;}case 3:{System.out.println(""+temp+"月为31天!!!");break;}case 4:{System.out.println(""+temp+"月为30天!!!");break;}case 5:{System.out.println(""+temp+"月为31天!!!");break;}case 6:{System.out.println(""+temp+"月为30天!!!");break;}case 7:{System.out.println(""+temp+"月为31天!!!");break;}case 8:{System.out.println(""+temp+"月为31天!!!");break;}case 9:{System.out.println(""+temp+"月为30天!!!");break;}case 10:{System.out.println(""+temp+"月为31天!!!");break;}case 11:{System.out.println(""+temp+"月为30天!!!");break;}case 12:{System.out.println(""+temp+"月为31天!!!");break;}default:{System.out.println("输入的月份有误!!!");break;}}}}public class SwitchDemo{public static void main(String args[]){int temp=0;Switch sw=new Switch();System.out.print("请输入月份:");Scanner scan=new Scanner(System.in);temp=scan.nextInt();sw.contains(temp);}} 楼主,别忘了给分哦~~~

public static void main(String[]args) { char ch=0;int a[]=new int[100];try{ int i=0;记录字母个数 System.out.println(\"请输入一个字符,以'#'结束\");do{ ch=(char)System.in.read();i+;a[i-

4a328cb1b9b450a8bad2cab61bf33b29.png

按照你的要求编写的求阶乘的Java程序如下import java.util.Scanner;public class DDD {public static void main(String[]args){System.out.print("请输入一个正整数(1~10)");Scanner sc=new Scanner(System.in);int n=sc.nextInt();if(n|n>10){System.out.println("无效数据!return;}System.out.print(n+!int result=1;for(int i=1;i;i+){result=result*i;if(i=n)System.out.print(i+"=");elseSystem.out.print(i+"x");}System.out.print(result);}}运行结果请输入一个正整数(1~10)44!1x2x3x4=24内容来自www.mh456.com请勿采集。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值