Skip to content

Instantly share code, notes, and snippets.

@siritori
Created May 13, 2014 01:30
Show Gist options
  • Save siritori/d3f47e23223f185dd9c2 to your computer and use it in GitHub Desktop.
Save siritori/d3f47e23223f185dd9c2 to your computer and use it in GitHub Desktop.
情報科学I
public class Letter
{
public static void main(String args[]) {
char ch = args[0].charAt(0);
System.out.println("Input a letter[A-E] : " + ch);
switch(ch) {
case 'A':
System.out.println("Excellent");
break;
case 'B':
System.out.println("Very Good");
break;
case 'C':
System.out.println("Good");
break;
case 'D':
System.out.println("Fair");
break;
case 'E':
System.out.println("Poor");
break;
default:
System.err.println("letter error : Unknown character '" + ch + "'");
}
}
}
public class ScopeOfNum
{
public static void main(String args[]) {
int num = Integer.parseInt(args[0]);
if(num >= 0 && num < 10) {
System.out.println(num + " is OK");
} else {
System.out.println(num + " is NG");
}
}
}
public class Star
{
public static void main(String args[]) {
int num_stars = Integer.parseInt(args[0]);
System.out.println("input number : " + num_stars);
for(int i = 0; i < num_stars; i++) System.out.print("*");
}
}
public class Star2
{
public static void main(String args[]) {
int num_stars = Integer.parseInt(args[0]);
System.out.println("input number : " + num_stars);
int i = 0;
while(i < num_stars) {
System.out.print("*");
i++;
}
}
}
public class Star3
{
public static void main(String args[]) {
int num_stars = Integer.parseInt(args[0]);
System.out.println("input number : " + num_stars);
int i = 0;
while(true) {
if(i == num_stars) break;
System.out.print("*");
i++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment