Results 1 to 9 of 9
  1. #1
    enteng420 is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default hi can anyone help me with this?

    create a program that accepts the full name of a student. the program should count and display all the vowels and consonants. we cannot use array and the program must loop.

    here's the sample output:
    Enter student name: John Brown
    There are 2 vowels and 7 consonants

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Hello, and welcome to the forum.

    So in essence what you've done is to give us your entire assignment without asking a question, and I'm afraid that in this situation there's not much that we can do for you other than to direct you to a tutorial or two.

    I suggest that you post your best solution that you've created so far, and ask as specific questions as possible, and we'll be much better able to help. If you really have no idea how to begin here, then please have a look here: Starting Writing a Program. It's a well-written article that can help.

    Much luck

  3. #3
    enteng420 is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    Hello, and welcome to the forum.

    So in essence what you've done is to give us your entire assignment without asking a question, and I'm afraid that in this situation there's not much that we can do for you other than to direct you to a tutorial or two.

    I suggest that you post your best solution that you've created so far, and ask as specific questions as possible, and we'll be much better able to help. If you really have no idea how to begin here, then please have a look here: Starting Writing a Program. It's a well-written article that can help.

    Much luck
    thanks for replying. im really a newbie in making programs in java. here's what i made.

    Java Code:
    import java.io.*;
    import javax.swing.*;
    import java.util.*;
    class mp1test
    {
    	public static void main(String args[])throws IOException
    	{
    	  final String consonants = "bcdfghjklmnpqrstvwxz" +
    	                          "BCDFGHJKLMNPQRSTVWXZ";
    	  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    	  num=Integer.parseInt(br.readLine());
    	  char ch;
    	  char answer;
    	  String Vowels;
    	  String Consonants;
    	  System.out.println("Enter Full name of student");
    	  System.in.read();System.in.read();
    	  System.out.println("There are "+vowels  +consonants);
            for (int i = 0; i < total; i++) {
                char ch = inputString.charAt(i);
                if ((ch == 'a') || (ch == 'A') || (ch == 'e') || (ch == 'E') || (ch == 'i') || (ch == 'I') || (ch == 'o') || (ch == 'O') || (ch == 'u') || (ch == 'U'))
    {
                    numVowels++;
    		{
                elseif(Character.isLetter(ch)); 
    		numCons++;
    		}
                    
    	}
    	}
    	}
    could you help me with this? :)

    Moderator Edit: Code tags added
    Last edited by Fubarable; 06-19-2010 at 06:00 AM. Reason: Moderator Edit: Code tags added

  4. #4
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    As Fubarable posted, you first need to ask a question. This means that you need to tell us how your current code doesn't work or what specific aspect do you not understand?

  5. #5
    enteng420 is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default

    mp1test.java:31: reached end of file while parsing
    }→
    ^
    1 error

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Note, I added code tags in your post above to help make your code readable. To see how to do this yourself, please look at my signature.

    Much luck!

  7. #7
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by enteng420 View Post
    mp1test.java:31: reached end of file while parsing
    }→
    ^
    1 error
    I'm not even able to compile your code due to many errors: num not declared, vowels not declared, total and inputString not declared. Is this the actual program that you have run and that generated the error you mention above? I'm sorry, but it just can't be. For better help, please post the compilable version of your program.

  8. #8
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Also (1): what is the purpose for this line?:
    Java Code:
    num=Integer.parseInt(br.readLine());
    Again, num is never declared and also, it's never used, so why even have it in your code?

    Also (2): If you're going to create a BufferedReader object, br, to get user input from the keyboard, you might as well use this to get the user input. So get rid of these statements:
    Java Code:
    System.in.read();System.in.read();
    as they serve no useful purpose here and instead use your br variable.

    Hm,... as I'm looking through your program, it appears almost as if you tried to cobble together a program using bits and pieces of code from other programs without knowing what the code does. This won't work ever. You'll need to go over your lesson notes, text and tutorials to understand what each bit of code does before you try to use it.

    Suerte

  9. #9
    Bulelakes is offline Member
    Join Date
    Jul 2010
    Posts
    32
    Rep Power
    0

    Default

    if you getting the data from JOptionPane

    Use these steps:

    //declaration
    int vowels;
    int consonant;
    String name;

    //then ask the user to enter the name

    //convert name into char

    //check vowels and consonants using "if" statement
    //display the name and number of vowels and consonants.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •