Created
July 5, 2011 11:03
-
-
Save wingyplus/1064657 to your computer and use it in GitHub Desktop.
lab test for Nong Ying
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
public class test { | |
public static void main(String args[]) { | |
int x = 1; | |
while(x != 0) { | |
x = Integer.valueOf(System.console().readLine("enter number: ")); | |
switch (x) { | |
case 1: oddnum(); | |
break; | |
case 2: evennum(); | |
break; | |
case 3: print(); | |
break; | |
} | |
} | |
} | |
private static void oddnum() { | |
int x = Integer.valueOf(System.console().readLine("enter x: ")); | |
int y = Integer.valueOf(System.console().readLine("enter y: ")); | |
int z = Integer.valueOf(System.console().readLine("enter z: ")); | |
for (int i = x; i <= y; i++) { | |
if (i % z == 0 && i % 2 == 1) { | |
System.out.print(i + " "); | |
} | |
} | |
System.out.println(); | |
} | |
private static void evennum() { | |
} | |
private static void print() { | |
int x = Integer.valueOf(System.console().readLine("enter number x: ")); | |
String seq = "AZYXWVUTSRQPONMLKJIHGFEDCB"; | |
if(x != 0) { | |
seq = seq.substring(x) + seq.substring(0, x); | |
} | |
System.out.println(seq); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
substring(x) มันคือตีดตั้งแต่ index x ถึงตัวสุดท้าย
substring(0, x) คือให้มันตัดตั้งแต่ตัวแรกถึง x - 1