Skip to content

Instantly share code, notes, and snippets.

@komo91
Created March 6, 2015 10:27
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 komo91/d232c7b3b31efd52dc8e to your computer and use it in GitHub Desktop.
Save komo91/d232c7b3b31efd52dc8e to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Yakyukiroku {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("あなたはピッチャー?(0)バッター?(1)");
int q = sc.nextInt();
switch (q) {
case 0:
bougyo();
break;
case 1:
daritsu();
break;
default:
System.out.println("最初の説明文しっかり読んで!");
}
}
public static void daritsu() {
Scanner sc = new Scanner(System.in);
System.out.println("打率計算します。\n打数はいくつ?");
int dasekisu = sc.nextInt();
System.out.println("安打数は?");
int anda = sc.nextInt();
double daritsu = (double)anda / (double)dasekisu;
System.out.printf("打率は%5.3f\n",daritsu);
}
public static void bougyo() {
Scanner sc = new Scanner(System.in);
System.out.println("防御率計算します。\n自責点はいくつ?");
int ziseki = sc.nextInt();
System.out.println("投球回数は?\nこの時投球回数が1/3回=0.3,2/3回=0.6で計算してください。");
double toukyu = sc.nextDouble();
double bougyo = (double)ziseki * 9 / toukyu;
System.out.printf("防御率は%4.2f\n",bougyo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment