|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
// Ive been banging my head on the wall trying to get this pgm to work for a couple days now.
// Can any one help me? // Write a program that asks the user's name, and then greets the user by name. // Before outputting the user's name, convert it to upper case letters. // For example, if the user's name is Fred, then the program should respond // "Hello, FRED, nice to meet you!". import java.io.*; public class ques1 { public static void main(String[] args) { String userName; // userName, as entered by the user String upperCaseName; // usersName, converted to uppercase letters. try{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Please enter your name: "); userName = reader.readLine( ); userName = userName.toUpperCase(); upperCaseName = userName; System.out.println("Hello, " + upperCaseName + ", nice to meet you!"); } catch (IO exception io){} // end main() } // end class |
|
#2
|
|||
|
|||
|
Change
to Also, it looks like you're missing the main() closing bracket. |
|
#3
|
|||
|
|||
|
One comment.
As a beginner, it is always good if you lern to indent the code. This helps you when it comes to finding errors. Programming (Assignment/Project) Help |
|
#4
|
||||
|
||||
|
The forum strips white space if you don't wrap your code with [code][/code] tags when posting.
Indenting, and pasting in the forum, makes reading the code easier.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > I am a beginner and Im having trouble with this Java Lab. I think its almost done! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|