Skip to content

Instantly share code, notes, and snippets.

@AuroraNorthernQuarter
Created December 23, 2018 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AuroraNorthernQuarter/1d97d3bb5e5ad9061105b2b8fa49180f to your computer and use it in GitHub Desktop.
Save AuroraNorthernQuarter/1d97d3bb5e5ad9061105b2b8fa49180f to your computer and use it in GitHub Desktop.
サンプルコード7-2
package testprogramm;
import java.util.Scanner;
class oshiete {
public void livingthing() {
Scanner scan = new Scanner(System.in);
System.out.print("種別を入力してください: ");
String hensuunitsusite = scan.nextLine();
String syubetsu[] = new String[4];
String animal[] = new String[4];
String tousuu[] = new String[4];
syubetsu[0] = "動物";
syubetsu[1] = "動物";
syubetsu[2] = "動物";
syubetsu[3] = "植物";
animal[0] = "キリン";
animal[1] = "ライオン";
animal[2] = "ゴリラ";
animal[3] = "ひまわり";
tousuu[0] = "7頭";
tousuu[1] = "3頭";
tousuu[2] = "5頭";
tousuu[3] = "1本";
for (int i = 0; i < 4; i++) {
if (hensuunitsusite.equals(syubetsu[i])) {
System.out.println(animal[i]);
System.out.println(tousuu[i]);
}
else {
System.out.println("種別がありません。再度入力してください。");
}
}
scan.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment