Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Last active October 4, 2016 11:39
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 mokomokohitsuzi/17d58d332d5b89d66c5d660a0c0db6b6 to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/17d58d332d5b89d66c5d660a0c0db6b6 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習2-6
import java.util.Scanner;
public class En2_6 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.println("三角形の面積を求めます。");
// 実数を読み込み
System.out.print("底辺:");
double bottom = stdIn.nextDouble();
System.out.print("高さ:");
double top = stdIn.nextDouble();
// 三角形の面積は底辺×高さ÷2
System.out.println("面積は" + (bottom * top) / 2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment