Last active
October 4, 2016 11:39
-
-
Save mokomokohitsuzi/17d58d332d5b89d66c5d660a0c0db6b6 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習2-6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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