Ex. 輸入月份,輸出"大月"、"小月"
可參考"分數轉等第"
herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
計算你的BMI
-
1. 利用遞迴input n算2^n 2. 用C算GCD(3333,456)
-
請用 C/C++/java寫一簡易程式
-
33, 45, 87, 99, 27 算平均
-
一、 試利用switch case由程式中直接輸入一個1~7 之間的整數day,代表星期一到星期日。若day 的值是1,則印出 "星期一",若day 的值是2,則印出 "星期二",若day 的值是7,則印出 "星期日",...
-
BMI (Body Mass Index)= 體重 (kg) / 身高 ^2(m 2 ) 在台灣,行政院衛生署乃根據其相關研究,於2002年4月公佈台灣成人肥胖標準: BMI<18.5 為過輕, 18.5≦BMI<24 為正常體重, 24≦BMI<27 為過重, BM...
-
需要練習的Java程式:
-
用 C/C++算上學期加權平均
41 則留言:
import java.util.Scanner;
public class ex1
public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("輸入月份"); int x=input.nextInt(); if(x<1 || x>12) System.out.println("錯誤"); else if (x==1) System.out.println("大月"); else if (x==3) System.out.println("大月"); else if (x==5) System.out.println("大月"); else if (x==7) System.out.println("大月"); else if (x==8) System.out.println("大月"); else if (x==10) System.out.println("大月"); else if (x==12) System.out.println("大月"); else System.out.println("小月"); }
import java.util.Scanner;
public class ex {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int x = input.nextInt();
if (x<=0 || x>13) System.out.println("錯誤");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println("大月"); break;
default:
System.out.println("小月");
}
}
}
}
import java.util.Scanner; public class ex2 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = input.nextInt(); if(x<0||x>12) System.out.println("錯誤"); else{ switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("大月"); break; case 4: case 6: case 9: case 11: System.out.println("小月"); break; default: System.out.println("28或29天"); } } } }
import java.util.*; public class EX { public static void main(String[] args) { Scanner input= new Scanner(System.in); int x= input. next Int (); if(x<0 ||x>13) System.out.print("請輸入1-12的數字"); else{ switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.print("大月");break; case 4: case 6: case 9: case 11: System.out.print("小月");break; case 2 : System.out.print("2月比較特別呀 28天或29天"); } } } }
輸入 2
2月比較特別呀 28天或29天
import java.util.*; public class A {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x = input.nextInt();
if(x<1 || x>12) System.out.print("錯誤");
else switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.print("大月");break;
case 4: case 6: case 9: case 11:
System.out.print("小月");break; default:System.out.print("二月");
}
}
}
package ex1;
import java.util.Scanner;
public class ex2 {
public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("輸入月份:"); int x=input.nextInt(); if (x<1 || x>12) System.out.println("mistake"); else { switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("大月"); break; default: System.out.println("小月"); break; } }
}
}
輸入月份:
13
mistake
import java.util.Scanner;
public class EDF { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x=input.nextInt(); if(x<0 || x>12) System.out.println("錯誤"); else switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: System.out.println("31"); case 2: System.out.println("28"); default: System.out.println("30"); } } }<
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x){
case 1:
System.out.println("31");break;
case 2:
System.out.println("28");break;
case 3:
System.out.println("31");break;
case 4:
System.out.println("30");break;
case 5:
System.out.println("31");break;
case 6:
System.out.println("30");break;
case 7:
System.out.println("31");break;
case 8:
System.out.println("31");break;
case 9:
System.out.println("30");break;
case 10:
System.out.println("31");break;
case 11:
System.out.println("30");break;
case 12:
System.out.println("31");break;
default:
System.out.println("錯誤");
}
}
}
import java.util.Scanner;
public class ex1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n=input.nextInt();
switch(n){
case 1:
System.out.println("31");break;
case 2:
System.out.println("28");break;
case 3:
System.out.println("31");break;
case 4:
System.out.println("30");break;
case 5:
System.out.println("31");break;
case 6:
System.out.println("30");break;
case 7:
System.out.println("31");break;
case 8:
System.out.println("31");break;
case 9:
System.out.println("30");break;
case 10:
System.out.println("31");break;
case 11:
System.out.println("30");break;
case 12:
System.out.println("31");break;
default:
System.out.println("錯誤");
}
}
}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x){
case 1:
System.out.println("31");break;
case 2:
System.out.println("28");break;
case 3:
System.out.println("31");break;
case 4:
System.out.println("30");break;
case 5:
System.out.println("31");break;
case 6:
System.out.println("30");break;
case 7:
System.out.println("31");break;
case 8:
System.out.println("31");break;
case 9:
System.out.println("30");break;
case 10:
System.out.println("31");break;
case 11:
System.out.println("30");break;
case 12:
System.out.println("31");break;
default:
System.out.println("錯誤");
}
}
}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x){
case 1:
System.out.println("31");break;
case 2:
System.out.println("28");break;
case 3:
System.out.println("31");break;
case 4:
System.out.println("30");break;
case 5:
System.out.println("31");break;
case 6:
System.out.println("30");break;
case 7:
System.out.println("31");break;
case 8:
System.out.println("31");break;
case 9:
System.out.println("30");break;
case 10:
System.out.println("31");break;
case 11:
System.out.println("30");break;
case 12:
System.out.println("31");break;
default:
System.out.println("錯誤");
}
}
}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x){
case 1:
System.out.println("31");break;
case 2:
System.out.println("28");break;
case 3:
System.out.println("31");break;
case 4:
System.out.println("30");break;
case 5:
System.out.println("31");break;
case 6:
System.out.println("30");break;
case 7:
System.out.println("31");break;
case 8:
System.out.println("31");break;
case 9:
System.out.println("30");break;
case 10:
System.out.println("31");break;
case 11:
System.out.println("30");break;
case 12:
System.out.println("31");break;
default:
System.out.println("錯誤");
}
}
}
import java.util.*;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(x<=0|x>12) System.out.println("錯誤");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10:
case 12:
System.out.println("大月");break;
case 2: case 4: case 6: case 9: case 11:
System.out.println("小月");break;
}
}
}
}
import java.util.*;
public class EX01 {
public static void main(String[] args) { Scanner intput=new Scanner(System.in); System.out.println("輸入月份:"); int x=intput.nextInt(); if(x<1 || x>12) System.out.println("錯誤"); else { switch(x){ case 1: case 3:case 5:case 7: case 8:case 10:case 12: System.out.println("大月");break; default: System.out.println("小月");break; } } }}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x){
case 1:
System.out.println("31");break;
case 2:
System.out.println("28");break;
case 3:
System.out.println("31");break;
case 4:
System.out.println("30");break;
case 5:
System.out.println("31");break;
case 6:
System.out.println("30");break;
case 7:
System.out.println("31");break;
case 8:
System.out.println("31");break;
case 9:
System.out.println("30");break;
case 10:
System.out.println("31");break;
case 11:
System.out.println("30");break;
case 12:
System.out.println("31");break;
default:
System.out.println("錯誤");
}
}
}
import java.util.Scanner;
public class ex02 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("輸入月份:");
int x=input.nextInt();
if (x<1 || x>12) System.out.println("錯誤");
else {
switch(x){
case 1: case 3: case 5: case 7:
case 8: case 10: case 12:
System.out.println("大月"); break;
default:
System.out.println("小月"); break;
}
}
}
}
import java.util.*;
>public class ex02 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in); System.out.println("輸入月份");
int x=input.nextInt();
if(x<1 || x>12)
System.out.println("錯誤");
else {
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("大月"); break;
default:
System.out.println("小月"); } } } }
輸入月份
5
大月
import java.util.Scanner;
public class ex02 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("輸入月份:");
int x=input.nextInt();
if (x<1 || x>12) System.out.println("error");
else {
switch(x){
case 1: case 3: case 5: case 7:
case 8: case 10: case 12:
System.out.println("大月"); break;
default:
System.out.println("小月"); break;
}
}
}
}
import java.util.*;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in); System.out.println("輸入月份");
int x=input.nextInt();
if (x<1 || x>12) System.out.println("錯誤");
else { switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("大月"); break;
default:
System.out.println("小月"); } } }
}
輸入月份
6
小月
import java.util.Scanner;
public class ex02 {
public static void main(String[] args) {
System.out.println("hello");
Scanner input=new Scanner(System.in); System.out.println("輸入月份:");
int x=input.nextInt();
if (x<1 || x>12) System.out.println("錯誤");
else {
switch(x){
case 1: case 3:case 5:case 7: case 8: case 10:case 12: System.out.println("大月"); break;
default:
System.out.println("小月"); break;
}
}
}
}
import java.util.*;
public class game1 {
public static void main(String[] args) { Scanner input=new Scanner(System.in); int x=input.nextInt(); if(1>x || x>12) System.out.println("錯誤"); else switch(x){ case 1 : case 3 : case 4 : case 5 : case 6 : case 7 : case 8 : case 9 : case 10 : case 11 : case 12: System.out.println("大月"); break; default: System.out.println("小月"); } } }
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x){
case 1:
System.out.println("31");break;
case 2:
System.out.println("28");break;
case 3:
System.out.println("31");break;
case 4:
System.out.println("30");break;
case 5:
System.out.println("31");break;
case 6:
System.out.println("30");break;
case 7:
System.out.println("31");break;
case 8:
System.out.println("31");break;
case 9:
System.out.println("30");break;
case 10:
System.out.println("31");break;
case 11:
System.out.println("30");break;
case 12:
System.out.println("31");break;
default:
System.out.println("錯誤");
}
}
}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x){
case 1:
System.out.println("31");break;
case 2:
System.out.println("28");break;
case 3:
System.out.println("31");break;
case 4:
System.out.println("30");break;
case 5:
System.out.println("31");break;
case 6:
System.out.println("30");break;
case 7:
System.out.println("31");break;
case 8:
System.out.println("31");break;
case 9:
System.out.println("30");break;
case 10:
System.out.println("31");break;
case 11:
System.out.println("30");break;
case 12:
System.out.println("31");break;
default:
System.out.println("錯誤");
}
}
}
import java.util.*;
public class EX01 {
public static void main(String[] args) { Scanner intput=new Scanner(System.in); System.out.println("輸入月份:"); int x=intput.nextInt(); if(x<1 || x>12) System.out.println("錯誤"); else { switch(x){ case 1: case 3:case 5:case 7: case 8:case 10:case 12: System.out.println("大月");break; default: System.out.println("小月");break; } } }}
package ex1; import java.util.Scanner; public class ex2 { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("輸入月份"); int x=input.nextInt(); if (x<1 || x>12) System.out.println("錯誤"); else { switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("大月");break; default: System.out.println("小月");break; } }
import java.util.Scanner;
public class ex02 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("輸入月份:");
int x=input.nextInt();
if (x<1 || x>12) System.out.println("錯誤");
else {
switch(x){
case 1: case 3: case 5: case 7:
case 8: case 10: case 12:
System.out.println("大月"); break;
default:
System.out.println("小月"); break;
}
}
}
}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
System.out.println("嗨");
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(1>x || x>12) System.out.println("錯誤");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println("大月");
break;
default:
System.out.println("小月");
}
}
}
}
package ex1;
import java.util.Scanner;
public class ex2 {
public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("輸入月份:"); int x=input.nextInt(); if (x<1 || x>12) System.out.println("mistake"); else { switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("大月"); break; default: System.out.println("小月"); break; } }
}
}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
System.out.println("嗨");
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(1>x || x>12) System.out.println("錯誤");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println("大月");
break;
default:
System.out.println("小月");
}
}
}
}
import java.util.Scanner;
public class ex1 {
public static void main(String[] args) {
System.out.println("請輸入月份:");
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(1>x||x>12) System.out.println("error");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println("大月");
break;
default:
System.out.println("小月");
}
}
}
import java.util.Scanner;
public class month1 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(1>x || x>12) System.out.println("error");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println("大月");
break;
default:
System.out.println("小月");
}
}
}
}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
System.out.println("嗨");
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(1>x || x>12) System.out.println("錯誤");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println("大月");
break;
default:
System.out.println("小月");
}
}
}
}
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
System.out.println("嗨");
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(1>x || x>12) System.out.println("錯誤");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println("大月");
break;
default:
System.out.println("小月");
}
}
}
}
package ex01;
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int x = input.nextInt();
if(x<1 || x>12) System.out.println("error");
else{
switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println("大月");
break;
default :
System.out.println("小月");
}
}
}
}
import java.util.Scanner;
public class ex02 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("輸入月份:");
int x=input.nextInt();
if (x<1 || x>12) System.out.println("錯誤");
else {
switch(x){
case 1: case 3: case 5: case 7:
case 8: case 10: case 12:
System.out.println("大月"); break;
default:
System.out.println("小月"); break;
}
}
}
}
package ex01;
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) { Scanner input=new Scanner(System.in); int x=input.nextInt(); if(x<1 || x>12) System.out.println("error"); else{ switch(x){ case 1: case 3: case 5: case 7: case 8 : case 10 : case 12: System.out.println("大月"); break; default : System.out.println("小月"); } } }
輸入月份
6
小月
import java.util.*; public class EX1 { public static void main(String[] args) { Scanner input= new Scanner(System.in); int x=input.nextInt(); if(x<1 ||x>13) System.out.print("請輸入1-12的數字"); else{ switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.print("大月");break; case 4: case 6: case 9: case 11: System.out.print("小月");break; case 2 : System.out.print("2月比較特別呀 28天或29天"); } } } }
package ex1;
import java.util.Scanner;
public class ex2 {
public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("輸入月份:"); int x=input.nextInt(); if (x<1 || x>12) System.out.println("mistake"); else { switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("大月"); break; default: System.out.println("小月"); break; } }
}
}
輸入月份:
13
mistake
package ex01;
import java.util.Scanner;
public class ex01 {
public static void main(String[] args) { System.out.println("A"); Scanner input=new Scanner(System.in); int x=input.nextInt(); if(112) System.out.println("error"); else{ switch(x){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("big moon"); break; default: System.out.println("small moon"); } } }
import java.util.*;
public class ex01 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in); System.out.println("輸入月份");
int x=input.nextInt();
if (x<1 || x>12) System.out.println("錯誤");
else { switch(x){
case 1: case 3: case 5: case 7: case 8: case 10: case 12: System.out.println("大月"); break;
default:
System.out.println("小月"); } } }
}
import java.util.*;
public class m123 {
public static void main(String[] args) { Scanner input=new Scanner(System.in); int x=input.nextInt(); if(1>x||x>12)System.out.println("error"); else switch (x) { case 1:case 3:case 5:case 7:case 8:case 10:case 12: System.out.println("大月31"); break; case 4:case 6:case 9:case 11: System.out.println("小月30"); break; case 2: System.out.println("小月28、29"); break; } } }
張貼留言