|
1. Write a Java application that can output 26 Greek letters. Hint: We need to find the ASCII value of the first Greek letter.
2. Write a Java application, the user from the keyboard to enter the number between a 1~9999, the program will determine the number of digits, and determine whether this number is a palindrome number. Palindrome number refers to the number of numbers contained in reverse order after the number and the original number of the same, such as 12121, 3223 are palindrome number. Code appended.
3. Guess the number game. Write a Java application that implements functionality:
(1) The program randomly assigns to the user a random number between 1~100
(2) Users enter their own guesses in the input dialog box
(3) The program returns the prompt information, the clue information is: "Guess big", "Guess small", "guessed right"
(4) The user may enter the guess again according to the prompt information, until the prompt information is "guessed right". Code appended. |
|
public class Greek {
/**
* @param args */public
static void Main (string[] args) {
//TODO Auto-gene Rated method Stub
Printgreek ();
}
static void Printgreek ()
{
char a = ' alpha ';
int m = (int) A;
for (int i=m;i<=m+24;i++)
{
System.out.println ((char) i);
}
}
}
Import Javax.swing.JOptionPane;
public class Testnumber {public static void main (String args[]) {loopnumber ();
The static void Loopnumber () {int number = 0,D5,D4,D3,D2,D1;
String Str=joptionpane.showinputdialog ("Enter a number between 1 and 99999");
Number = Integer.parseint (str); if (number >= 1&&number <= 99999)//judge the condition of number between 1 and 99999 {d5=number%100000/100 00;//calculates the highest bit (million) D5 d4=number%10000/1000; The thousand D4 d3=number%1000/100 of number is computed;
The Hundred D3 D2=NUMBER%100/10 that calculates number;
d1=number%10;
if (D5 > 0)//Judging number is a 5-digit condition {System.out.println (number+ "is 5 digits"); if (d5 = = D1 && D2 = = D4)//Judge number is the condition of palindrome numbers {System.out.println (number+)
is a palindrome number ");
} else {System.out.println (number+ "not palindrome number"); } else if (D4 > 0)//To determine if number is a 4-digit condition {SYSTEM.OUT.PR
Intln (number+ "is 4 digits"); if (D1 = = D4 && D2 = = D3)//Judge number is a palindrome of the conditional code {SYSTEM.OUT.PRINTLN
+ "is palindrome number");
else {System.out.println (number+ "not palindrome number"); } else if (D3 > 0)//To determine if number is a 3-digit condition {SYSTEM.O
Ut.println (number+ "is 3 digits");
if (D1 = = D3)//Judge number is the condition of palindrome numbers {System.out.println (number+ "is palindrome number");
else {System.out.println (number+ "not palindrome number"); } else if (d2!=0) {System. OUT.PRINTLN (number+ "is 2 digits");
if (D1==D2) {System.out.println (number+ "is a palindrome number");
else {System.out.println (number+ "not palindrome number");
} else if (d1!=0) {System.out.println (number+ "is 1 digits");
System.out.println (number+ "is palindrome number");
} else {System.out.printf ("\n%d not between 1 and 99999", number);
}
}
}
import Javax.swing.JOptionPane; public class Guessnumber {public static void main (String arg
S[]) {guess ();
static void Guess () {System.out.println ("give you an integer between 1 and 100, please guess this number");
int realnumber= (int) (Math.random () *100) +1;
int yourguess=0;
String str=joptionpane.showinputdialog ("Enter your guess:");
Yourguess=integer.parseint (str);
while (yourguess!= realnumber)//Loop condition {if (yourguess > RealNumber)//condition code {
Str=joptionpane.showinputdialog ("Guess big, then enter your guess:");
Yourguess=integer.parseint (str); else if (Yourguess < RealNumber)//condition code {str=joptionpane.showinputdial
OG ("Guess small, then enter your guess:");
Yourguess=integer.parseint (str);
} System.out.println ("guessed right!"); }
}