| | |
please help me.. [info inside]
![]() |
i have a problem for this program .
how can i use the program in the middle..
i tried to put it IN .. but many error exist..
please help me with my program .. thanks..
here's the output:
Enter Name: Simplicio
Enter Password: pOLOtAn
1 Capital constant letter/s
4 lower case consonant letter/s
0 capital Vowel letter/s
4lower case Vowel letter/s
Try Again?
how can i use the program in the middle..
i tried to put it IN .. but many error exist..
please help me with my program .. thanks..
here's the output:
Enter Name: Simplicio
Enter Password: pOLOtAn
1 Capital constant letter/s
4 lower case consonant letter/s
0 capital Vowel letter/s
4lower case Vowel letter/s
Try Again?
java Syntax (Toggle Plain Text)
import java.io.*; import java.awt.Graphics; import java.util.Random; import javax.swing.*; import java.util.Scanner; public class midquiz { public static void main (String [] args) throws IOException { //try { Scanner input = new Scanner(System.in); String name,pass,ans; String pass1="pOLOtAn"; int len; char len1[]; len1 = new char[20]; do { System.out.println ("Username must be 8 to 15 character only."); System.out.print("Enter Username:"); name = input.nextLine(); len = name.length(); if (len>= 8 && len<=15) { for (int b=0;b<1;b++) { System.out.print("Enter Password:"); pass=input.nextLine(); if(pass.equals(pass1)) { System.out.print("Alphabetical Order of your name is:"); for (int c=0;c<len;c++) { len1[c]=name.charAt(c); } //for(int d=1;d<len;d++) //{ // if (let[c]>let[d]) // { // char temp=let[c]; // let[c]=let[d]; // let[d]= temp; // } // } for (int c=0;c<len;c++) { System.out.println(len1[c]+""); } } else { System.out.println("You Have Enter Wrong PassWord "); System.exit(0); } } } else { System.out.println("ILLEGAL USER! GOODBYE...."); System.exit (0); } System.out.println("\n Try Again? [Yes/No]:"); ans=input.nextLine(); }while (ans.equalsIgnoreCase ("Yes")); } } }
uuhhmm..
the main problem of this program is..
i can't use the middle part of the code ,,
there is something wrong ..
it cannot run when i use the middle part of my program ..
hhmm.. sorry for my unclear explanation ..
please help me.. for this.. thanks alot..
the main problem of this program is..
i can't use the middle part of the code ,,
there is something wrong ..
it cannot run when i use the middle part of my program ..
hhmm.. sorry for my unclear explanation ..
please help me.. for this.. thanks alot..
it doesn't look like your code is written to do too much...
it runs fine, but fine depends on what you want it to do. if you are referring to the alphabetical ordering of characters, well it isn't happening because all you are doing is print the characters of the username in chronological order.
does that help?
it runs fine, but fine depends on what you want it to do. if you are referring to the alphabetical ordering of characters, well it isn't happening because all you are doing is print the characters of the username in chronological order.
does that help?
•
•
•
•
it doesn't look like your code is written to do too much...
it runs fine, but fine depends on what you want it to do. if you are referring to the alphabetical ordering of characters, well it isn't happening because all you are doing is print the characters of the username in chronological order.
does that help?
how will i do it?
please help me..
•
•
Join Date: Jul 2009
Posts: 24
Reputation:
Solved Threads: 2
Here you go. It's a bit rough, but it does what you wanted.
The main reason it's tough to understand is because you didn't
split all your code into separate methods. If you had defined different things using individual methods and then strung it all together in main then everything would be a lot more readable.
The main reason it's tough to understand is because you didn't
split all your code into separate methods. If you had defined different things using individual methods and then strung it all together in main then everything would be a lot more readable.
java Syntax (Toggle Plain Text)
import java.util.Scanner; public class midquiz { // Variables private static String name; private static String passInput; private static String ans; private static CharSequence userPass="PasswOrd"; private static int length; private static int passLength; private static int upperVowel = 0; private static int upperConsonant = 0; private static int lowerVowel = 0; private static int lowerConsonant = 0; public static void main (String [] args) { Scanner input = new Scanner(System.in); // Prompt for username System.out.print("Enter Username: "); name = input.nextLine(); length = name.length(); // Check appropriate length if (length < 8 || length > 15) { System.out.print("Username must be between 8 and 15 characters in length."); return; } else; // If name appropriate, then continue // Prompt for password System.out.print("Enter Password: "); passInput = input.nextLine(); // Verify password if (passInput.contentEquals(userPass)) { System.out.println("Password valid."); // If password is correct: for (;;) { passLength = passInput.length(); upperVowel = 0; upperConsonant = 0; lowerVowel = 0; lowerConsonant = 0; // Count the number of uppercase and number of lowercase consonants and vowels. for (int i = 0; i < passLength; ++i) { Character letter = new Character(passInput.charAt(i)); boolean isUpperCase = Character.isUpperCase(letter); boolean isLowerCase = Character.isLowerCase(letter); if (isUpperCase == true) { // Identifying vowels if ( letter.equals('A') || letter.equals('E') || letter.equals('I') || letter.equals('O') || letter.equals('U')) { // If it's a vowel then increase capitalized vowel count ++upperVowel; // ...otherwise, increase capitalized consonant count } else { ++upperConsonant; } } else if (isLowerCase == true){ // Identifying vowels if (letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o' || letter == 'u' ) { // If it's a vowel then increase lowercase vowel count ++lowerVowel; // ...otherwise, increase lowercase consonant count } else { ++lowerConsonant; } } else { // If you wanted to count digits as well, you could add that here. } } System.out.println("There are " +upperVowel+ " uppercase vowels."); System.out.println("There are " +upperConsonant+ " uppercase consonants."); System.out.println("There are " +lowerVowel+ " lowercase vowels."); System.out.println("There are " +lowerConsonant+ " lowercase consonants."); System.out.println("Try again (Re-count)? [Yes/No]: "); ans = input.nextLine(); if (ans.equalsIgnoreCase("no")) { System.exit(0); } else if (ans.equalsIgnoreCase("yes")) { } else { System.out.println("Invalid choice. Try again?"); } } } else; // If password is incorrect: System.out.println("Invalid password."); System.out.println("Try Again? [Yes/No]:"); ans=input.nextLine(); // If no if (ans.equalsIgnoreCase("no")) { System.exit(0); } else; // Whatever you want it to do. } }
Last edited by Godstryke; Jul 31st, 2009 at 1:36 pm.
![]() |
Similar Threads
- Info on top of Image (PHP)
- I can't get rid of this virus.. logs and info inside (Viruses, Spyware and other Nasties)
- Panels, different kinds, and how they work together. (Java)
- noob design help please (Database Design)
- read text file (C)
- read text file (C#)
- Need help creating and terminating processes in C++ (C++)
- Append to beginning of file (Visual Basic 4 / 5 / 6)
- Networking with dual adapters (Networking Hardware Configuration)
Other Threads in the Java Forum
- Previous Thread: Sorting problem once again....
- Next Thread: how to evaluate if it is EVEN or ODD number?
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class client code color component count database derby design eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui homework html ide if_statement image integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel jtextfield julia keyword linux list macintosh map method methods midlethttpconnection mobile netbeans newbie nullpointerexception object open-source os problem producer program programming project projectideas property read recursion reference replaysolutions ria scanner search server set size sms sort sourcelabs splash sql sqlite stop string swing threads transforms tree ui unicode validation windows






