Created
October 9, 2016 13:10
-
-
Save mokomokohitsuzi/5f2ffa083fd6398cb9820e8600b4010a to your computer and use it in GitHub Desktop.
新・明解Java入門 演習3-1
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 En3_1 { | |
public static void main(String[] args) { | |
Scanner stdIn = new Scanner(System.in); | |
System.out.print("絶対値:"); | |
int zettai = stdIn.nextInt(); | |
// 入力された数字が-の場合、-をかける。 | |
if (zettai < 0) { | |
zettai = -zettai; | |
} | |
System.out.println("その絶対値は" + zettai + "です。"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment