Created
May 9, 2014 01:44
-
-
Save siritori/32d57e796e97355b0a23 to your computer and use it in GitHub Desktop.
情報科学I
This file contains hidden or 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
public class Area | |
{ | |
public static void main(String args[]) { | |
double width = Integer.parseInt(args[0]); | |
double height = Integer.parseInt(args[1]); | |
System.out.println("Input Width : " + width); | |
System.out.println("Input Height : " + height); | |
System.out.println("Triangle Area : " + width * height / 2.0); | |
System.out.println("Square Area : " + width * height); | |
System.out.println("Circle Area : " + width * width * 3.14); | |
} | |
} |
This file contains hidden or 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
public class SalesTax | |
{ | |
public static void main(String args[]) { | |
if(args.length != 3) { | |
System.err.println("Invalid argument numbers"); | |
System.err.println("Please input Price, Year, and Month"); | |
return; | |
} | |
int price = Integer.parseInt(args[0]); | |
int year = Integer.parseInt(args[1]); | |
int month = Integer.parseInt(args[2]); | |
if(year < 0) { | |
System.err.println("Invalid month"); | |
return; | |
} | |
if(month < 0 || month > 12) { | |
System.err.println("Invalid year"); | |
return; | |
} | |
double tax_rate; | |
// if文を使う演習なので... | |
if(year >= 1998 || (year == 1997 && month >= 4)) { | |
// 1997年4月以降(1998年以降 + 1997年4~12月) | |
tax_rate = 0.05; | |
} else { | |
// 1997年4月以前 | |
tax_rate = 0.03; | |
} | |
System.out.println("Input Price : " + price); | |
System.out.println("Input Year : " + year); | |
System.out.println("Input Mounth : " + month); | |
System.out.println(""); | |
System.out.println("Sales tax : " + price * tax_rate); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment