herrDeng網內搜尋

自訂搜尋

Ads

2014年4月22日 星期二

Java練習(if-else/switch-case)

輸入1輸出one
輸入2輸出two
輸入其他int輸出other

32 則留言:

B10233061吳興強 提到...

package hello;
import java.util.*;
public class hello {

private static Scanner input;

public static void main(String[] args) {
System.out.println("other");
input = new Scanner(System.in);
int i=input.nextInt() ;
if (i==1) System.out.println("one");
else if (i==2) System.out.println("two");
else System.out.println("other");



}

}

B10233082 唐偉強 提到...

package ghghjgfhhgfh;
import java.util.*;
public class setgsddf {

public static void main(String[] args) {
System.out.println("輸入數字");
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
switch(x) {
case 1:
System.out.println("one");
break;
case 2:
System.out.println("two");
break;
default:
System.out.println("other");
}

}

}


B10233067 提到...

package hello0422;
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) System.out.println("ONE");
else if (x==2) System.out.println("TWO");
else System.out.println("OTHER");
}
}

B10233089 提到...

package hello0422;
import java.util.Scanner;
public class hello {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if (x==2) System.out.println("two");
else System.out.println("other");
}
}

B10233064莊英霆 提到...

import java.util.*;
public class hello {

private static Scanner input;

public static void main(String[] args) {
System.out.println("輸入值");
input = new Scanner(System.in);
int x=input.nextInt();
if(x==1) System.out.println("one");
else if (x==2) System.out.println("two");
else System.out.println("other");
}

}

B10233091 提到...

import java.util.Scanner;
public class ex2 {


private static Scanner imput;

public static void main(String[] args) {
System.out.println("import int");
imput = new Scanner(System.in);
int x=imput.nextInt();
if(x==1) System.out.println("one");
else if(x==2) System.out.println("two");
else System.out.println("other");

B10233072黃君寰 提到...

package ex1;

import java.util.Scanner;

public class hello2 {

public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x)
{
case 1: System.out.println("one"); break;
case 2: System.out.println("two"); break;
default: System.out.println("other");

}

}

}

B10233072黃君寰 提到...

package ex1;

import java.util.Scanner;

public class hello2 {

public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
switch(x)
{
case 1: System.out.println("one"); break;
case 2: System.out.println("two"); break;
default: System.out.println("other");

}

}

}

B10233069連于傑 提到...

package ex1;

import java.util.Scanner;

public class hello422 {

private static Scanner input;

public static void main(String[] args) {
System.out.println("input");
input = new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if (x==2) System.out.println("tow");
else System.out.println("other");

}

}

B10233092 提到...

package sss;
import java.util.*;
public class asd {

public static void main(String[] args) {
System.out.print("imput int");
Scanner input = new Scanner(System.in);
int i = input.nextInt();
if(i==1)System.out.println("one");
else if(i==2)System.out.println("two");
else System.out.println("other");
}

}

B10233062 黃聖評 提到...

package she;

import java.util.Scanner;

public class she57 {

private static Scanner input;


public static void main(String[] args) {
System.out.print("input int");
input = new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if (x==2) System.out.println("two");
else System.out.println("other");

}


}

B10233097 邱宥甄 提到...

package zz;

import java.util.Scanner;

public class ADF {

public static void main(String[] args) {
System.out.println("input int");
Scanner input =new Scanner(System.in);
int x=input.nextInt();
switch (x)
{
case 1 :System.out.println("one"); break;
case 2 :System.out.println("two"); break;
default:System.out.println("other");
}

}
}

b10233080陳芊慈 提到...

package ex1;

import java.util.*;

public class aaa {

public static void main(String[] args) {
System.out.println("input int");
Scanner input= new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if(x==2) System.out.println("two");
else System.out.println("other");
}

}

B10233081 藍立凱 提到...

package ex1;

import java.util.*;


public class ex1 {

public static void main(String[] args) {
System.out.println("import int");
Scanner imput=new Scanner(System.in);
int x=imput.nextInt();
if(x==1)System.out.println("one");
else if(x==2)System.out.println("two");
else System.out.println("other");




}

}

B10233090 提到...

package bbbb;
import java.util.*;
public class gsgsg {

private static Scanner imput;

public static void main(String[] args) {
System.out.print("imput int");
imput = new Scanner(System.in);
int i=imput.nextInt();
if(i==1) System.out.println("one");
else if (i==2) System.out.println("two");
else System.out.println("other");
}

}

B10233078 提到...

import java.util.Scanner;


public class WWW123 {

private static Scanner input;

public static void main(String[] args) {
input = new Scanner(System.in);
int x=input.nextInt();
switch(x)
{
case 1: System.out.println("one"); break;
case 2: System.out.println("two"); break;
default: System.out.println("other");
}

}

}

Y10211027張君弘 提到...

package ex1;

import java.util.Scanner;

public class hello422 {

private static Scanner input;

public static void main(String[] args) {
System.out.println("input int");
input = new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if(x==2) System.out.println("two");
else System.out.println("other");


}

}

B10233108 林宣瑋 提到...

package ex1;

import java.util.Scanner;

public class ex1 {

private static Scanner input;

public static void main(String[] args) {
System.out.println("input int");
input = new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if(x==2) System.out.println("two");
else System.out.println("other");

}

}

B10233098 陳孟緣 提到...

package aa;

import java.util.Scanner;

public class qq {

public static void main(String[] args) {
System.out.println("input int");
Scanner input =new Scanner(System.in);
int x=input.nextInt();
switch (x)
{
case 1 :System.out.println("one");break;
case 2 :System.out.println("two");break;
default:System.out.println("other");
}

}

}

B10233110徐上竣 提到...

package java;
import java.util.*;
public class javava {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(x==1) System.out.println("ONE");
else if (x==2) System.out.println("TWO");
else System.out.println("OTHER");
}
}

B10233087黃少洋 提到...

ackage free;

import java.util.Scanner;

public class free2 {

private static Scanner input;

public static void main(String[] args) { System.out.print("input int"); input = new Scanner(System.in); int x=input.nextInt(); if (x==1) System.out.println("one"); else if (x==2) System.out.println("two"); else System.out.println("other");

}

}

B10233076 提到...

package hello;

import java.util.*;

public class hello {

public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(x==1)System.out.println("one");
else if(x==2)System.out.println("two");
else System.out.println("other");

}

}

B10233063 張宜禎 提到...

package hello0422;

import java.util.*;

public class ex1 {

private static Scanner input;

public static void main(String[] args) {
input = new Scanner(System.in);
int x=input.nextInt();
switch(x)
{
case 1: System.out.println("one"); break;
case 2: System.out.println("two"); break;
default: System.out.println("other");
}
}
}

B10233107蔡育霖 提到...

package ex1;

import java.util.Scanner;

public class hello422 {

private static Scanner input;

public static void main(String[] args) {
System.out.println("input int");
input = new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if(x==2) System.out.println("two");
else System.out.println("other");


}

}

b10233109 提到...

package hello;

import java.util.*;

public class hello {

public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(x==1) System.out.println("ONE");
else if(x==2) System.out.println("TWO");
else System.out.println("OTHER");

}

}

B10233088 提到...

package hello;

import java.util.*;

public class hello {

public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
if(x==1) System.out.println("ONE");
else if(x==2) System.out.println("TWO");
else System.out.println("OTHER");

}

}

b10233096 提到...

package ex1;

import java.util.Scanner;

public class hello422 {

private static Scanner input;

public static void main(String[] args) {
System.out.println("input int");
input = new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if(x==2) System.out.println("two");
else System.out.println("other");


}

}

B10233066 提到...

package aaa;

import java.util.Scanner;

public class ggg {

private static Scanner input;

public static void main(String[] args) {
System.out.println("input int");
input = new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if(x==2) System.out.println("two");
else System.out.println("other");


}

}

B10233084 陳億如 提到...

package hello0422;

import java.util.Scanner;

public class ex1 {

public static void main(String[] args) {
Scanner input= new Scanner(System.in);
int x=input.nextInt();
switch(x)
{
case 1:System.out.println("one");break;
case 2:System.out.println("two");break;
default:System.out.println("other");break;
}

}
}

B10233075 提到...

package hello;

import java.util.*;

public class helloex2 {

private static Scanner input;

public static void main(String[] args) {
input = new Scanner(System.in);
int x=input.nextInt();
switch(x){
case 1:System.out.println("one");break;
case 2:System.out.println("two");break;
default:System.out.println("other");

}

B10233071 林政儒 提到...

package ex1;

import java.util.Scanner;

public class hello422 {

private static Scanner input;

public static void main(String[] args) {
System.out.println("input int");
input = new Scanner(System.in);
int x=input.nextInt();
if (x==1) System.out.println("one");
else if(x==2) System.out.println("two");
else System.out.println("other");


}

}

B10233074 許逸憲 提到...

package hello;
import java.util.*;
public class hello {

private static Scanner input;

public static void main(String[] args) {
System.out.println("other");
input = new Scanner(System.in);
int i=input.nextInt() ;
if (i==1) System.out.println("one");
else if (i==2) System.out.println("two");
else System.out.println("other");



}

}

Related Posts Plugin for WordPress, Blogger...

熱門文章