| View previous topic :: View next topic |
| Author |
Message |
Kingdom Grandmaster Cheater Supreme
Reputation: 0
Joined: 16 Jan 2007 Posts: 1638
|
Posted: Fri Apr 11, 2008 6:42 am Post subject: CONTEST!!!**JAVA PROGRAM** |
|
|
First person to finish gets a rep =)
Well here it is:
Write a program that prompts the user for a single character. Determine if the character is an upper case letter, a lower case letter, a digit or a symbol. Display a message accordingly. Display an error message if the user inputs more than one character.
Hint: Use the Character class.
Enjoy!
_________________
|
|
| Back to top |
|
 |
NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Fri Apr 11, 2008 7:22 am Post subject: |
|
|
| What for?
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Apr 11, 2008 7:55 am Post subject: |
|
|
Dude, the reason they assign this to you is so you can learn it for yourself. You won't learn shit if everyone does it for you -_-
_________________
|
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Fri Apr 11, 2008 10:45 am Post subject: |
|
|
You could use Character.isUpperCase() for that comparison, but you should do it by yourself, we are here to help people who are trying to learn, not to help them copy\paste.
As for a hint:
take a look at an ascii table and use int typecast on the character.
|
|
| Back to top |
|
 |
Ophiophagous How do I cheat?
Reputation: 0
Joined: 16 Jan 2007 Posts: 1 Location: Seattle
|
Posted: Fri Apr 11, 2008 5:21 pm Post subject: |
|
|
import java.util.Scanner;
import java.lang.Character;
public class win
{
public static void main (String[] args)
{
String leet;
Scanner scan = new Scanner(System.in);
System.out.println("Enter your string, mother fucka: ");
leet = scan.next();
char soss = leet.charAt(0);
if (leet.length() > 1)
System.out.println("error, more than one character");
else
{
if (Character.isLowerCase(soss))
System.out.println("lowercase letter");
if (Character.isUpperCase(soss))
System.out.println("Uppercase letter");
if (Character.isDigit(soss))
System.out.println("Digit");
if (!Character.isDigit(soss) && !Character.isLetter(soss))
System.out.println("Symbol");
}
}
}
need some java practice for AP test cause i r teh suck..
|
|
| Back to top |
|
 |
Kingdom Grandmaster Cheater Supreme
Reputation: 0
Joined: 16 Jan 2007 Posts: 1638
|
Posted: Wed Apr 16, 2008 7:05 am Post subject: |
|
|
Gave you your rep as promised.
=)
_________________
|
|
| Back to top |
|
 |
|