Error when entering 2 words, first/last name

here's my code:
public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int choice, status;
        String nm = "";
        double[] exams = new double[3];
        boolean newStudent = true;
        System.out.println("Enter the Maximum number of Students in the Course: ");
        int max_Students = scan.nextInt();
        COURSE newCourse = new COURSE(max_Students);
        do{
            choice = menu();
            switch(choice){
                case 0:
                    break;
                case 1:
                    while(newStudent){
                        if(max_Students > 0){
                        max_Students--;
                        System.out.println("Enter the students name: ");
                        nm = scan.next();
                        System.out.println("Enter the students status: 0-NoStatus, 1-FR, 2-SO, 3-JR, 4-SR, 5-GR");
                        status = scan.nextInt();
                        System.out.println("Enter the student's exam scores: ");
                        for(int x = 0; x < exams.length; x++)
                            exams[x] = scan.nextDouble();
                        newStudent = newCourse.addStudent(nm, 0, exams);
                        else
                            newStudent = false;
                    break;When i input "John Smith" for example(from the nm = scan.next() line of code), i get an error.But if i just enter "john" it's fine. The error is at the status = scan.nextInt(); line. I'm pretty new to Java, kinda have been learning fast and i'm not sure what i'm doing wrong. If anyone can help that would be great. Thx
Edited by: thesegelkster on Mar 7, 2008 11:18 PM

System.out.println("Enter the students name: ");
nm = scan.next();next() returns the next complete token. So it will stop at the space of "John Smith". Try nextLine() which will return a complete line.
http://java.sun.com/javase/6/docs/api/java/util/Scanner.html#nextLine()

Similar Messages

  • Address book. First & last names order problem

    Hi all, I'm having an issue with address book names not appearing in the right order, or more to the point first and last names not appearing in the right order - in fact it's exactly the same as:
    http://discussions.apple.com/thread.jspa?messageID=7471811#7471811
    However that solution doesn't work.
    Essentially, when I go into address book / prefs and click sort by firstname/lastname - the list updates, but when I click 'before last name' / 'following last name' nothing happens at all. The list is ordered by first name - as I want it, but I'm still getting the surname first.
    This has transferred over to my Touch as well so it's very frustrating! any ideas?
    thanks very much for your time

    Hi
    You want the first name first.
    Investigate this.
    Close Address Book
    Open the ~/Library/Preferences/com.apple.AddressBook.plist with Property List editor which comes with XCode.
    Look for the entry
    *ABNameDisplay Number 1*
    and change the 1 to 0 (zero)
    and save. This sets the name order to 'Before last name'
    If you don't have Xcode it might be on your Install DVD.

  • Remove First & Last Name Validation in Get Support

    Hi All,
       I have enabled the self management of password for portal users. I have to remove the First & Last Name validation  and make it optional, I have also made (ume.logon.logon_help.name_required = false)  in configtool and taken the restart of the server, but still it is validating the names.
    If anyone have removed the validation for the above, can help me.
    Thanks in advance.
    Regards
    Ponnusamy

    Hi Ponnuswamy,
    the right place to remove the validation is the par file of the login page.
    Get the par file from the portal. unzip the par file.
    under the PORTAL-INF\lib u will find the umelogonbase.jar
    Extrat the jar. get the java file named
    SAPMLogonLogic.java.
    Modify the piece of code in the java file.
    private void performForgotPassword()
            throws IOException, UMException, FeatureNotAvailableException {
            String methodname = "performForgotPassword";
            if (trace.bePath()) {
                trace.entering(methodname);
            try {
                String longUid = this.proxy.getRequestParameter(LogonBean.LONGUID);
                if (longUid != null) {
                    longUid = longUid.trim();
                // check for email id
                String email = this.proxy.getRequestParameter("email");
                String lastName = this.proxy.getRequestParameter("lastname");
                String firstName = this.proxy.getRequestParameter("firstname");
                String noteToAdmin = this.proxy.getRequestParameter("notetoadmin");
                IUser userFrom = UMFactory.getUserFactory().getUserByLogonID(longUid);
                if (email.equalsIgnoreCase(userFrom.getEmail()) &&
                        firstName.equalsIgnoreCase(userFrom.getFirstName()) &&
                        lastName.equalsIgnoreCase(userFrom.getLastName())) {
                    // email matched, assign a new password and email to user
                    String newPass = UMFactory.getSecurityPolicy().generatePassword();
                    IUserAccount ua = UMFactory.getUserAccountFactory()
                                                       .getMutableUserAccount(longUid);
                    ua.setPassword(newPass);
                    ua.save();
                    ua.commit();
    this is the original coding.
    remove the check for last name and first name in that
      if (email.equalsIgnoreCase(userFrom.getEmail()) &&
                        firstName.equalsIgnoreCase(userFrom.getFirstName()) &&
                        lastName.equalsIgnoreCase(userFrom.getLastName()))
    complie the java file. get the class and store it in the umelogonbase.jar . put the jar back in the original place. deploy the par.
    u will get the desire result.
    cheers,
    Sithi

  • Error when entering serial number to redeem digital copy.

    I recieved an error when entering the serial number for my digital copy of Juno and have been unable to download the digital copy into itunes.
    However I have since recieved a reciept from apple for the "purchase". Can the serial number be "unclaimed" so I can reenter and redownload the the file. Or will "check for purchases" simply restart the download if I have the Juno disk in the drive.

    The error was "Unable to connect to iTunes Music store .....". Which was not the case since I could quite happily move round the rest of the store.
    I haven't attempted "checking for purchases", since I just thought of it whilst writing the original post, and I am not at my home PC.
    But thanks for the sarcastic response anyway . I was hoping someone who had had a similar problem to me would be able to say. "Yep check for purchase will restart download process" or otherwise say nope , you've got to call apple. Hence the original question.
    Message was edited by: mlockley

  • I am trying to download Illustrator to my windows laptop.  I tried with CC but got an error when entering the license number.  So someone told me that CC is different from CS6 Illustrator, and I have a license only for CS6 Illustrator.  What is the correc

    I am trying to download Illustrator to my windows laptop.  I tried with CC but got an error when entering the license number.  So someone told me that CC is different from CS6 Illustrator, and I have a license only for CS6 Illustrator.  What is the correct link for CS6 Illustrator then?

    Downloadable installation files available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4, CS4 Web Standard | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  13 |12 | 11, 10 | 9, 8, 7
    Photoshop Elements:  13 |12 | 11, 10 | 9,8,7
    Lightroom:  5.7.1| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.window using the Lightroom 3 link to see those 'Important Instructions'.

  • Display first last name ecord

    source schema like 
    <ns0:empdetails xmlns:ns0="http://BizTalk_Server_Project3.Schema1">
      <employee>
        <FirstNmae>Kapil</FirstNmae>
        <lastname_x0020_></lastname_x0020_>
      </employee>
      <employee>
        <Firstname>Kiran</Firstname>
        <Lastname>Kumar</Lastname>
      </employee>
      <employee>
        <Firstname>Naresh</Firstname>
        <lastname>Kumar</lastname>
      </employee>
     </ns0:empdetails>
    destination will be 
    <employee>
        <Firstname>Kiran</Firstname>
        <Lastname>Kumar</Lastname>
      </employee>
    the first last name record should come and igoner another records if contains last name or not .

    You can acheieve this using Scripting functoid ( Script Type "Inline XSLT Call Template"). Refer to below XSLT script to use. Map output from this scripting functoid to destination node. 
    <xsl:template name="Employee">
    <xsl:if test="boolean(/*[local-name()='empdetails' and namespace-uri()='http://BizTalk_Server_Project3.Schema1'] /*[local-name()='employee' and namespace-uri()=''][lastname!= ''])">
    <employee>
    <Firstname>
    <xsl:value-of select="/*[local-name()='empdetails' and namespace-uri()='http://BizTalk_Server_Project3.Schema1'] /*[local-name()='employee' and namespace-uri()=''][lastname!= ''][1] /*[local-name()='Firstname' and namespace-uri()='']"/>
    </Firstname>
    <Lastname>
    <xsl:value-of select="/*[local-name()='empdetails' and namespace-uri()='http://BizTalk_Server_Project3.Schema1'] /*[local-name()='employee' and namespace-uri()=''][lastname!= ''][1] /*[local-name()='lastname' and namespace-uri()='']"/>
    </Lastname>
    </employee>
    </xsl:if>
    </xsl:template>
    Thanks,
    Pavan
    MCTS-Microsoft Biztalk Windows Server 2010

  • Why Address Book email addresses without first&last name stacked up under random names when moved to Lion?

    Often in Snow Leopard I would add an email address to my address book wihtout filling in the name fields. For example, Iif I got an email from [email protected], I would "add to address book but never fill out the card completely with the first and last names. The card showed with just an email address. Just left it as the email address. I never had any problems doing this and it always showed up as a single email address on a single card. Oh woe is me! When I moved to Lion I now have multiple unrelated email addresses under some of these "email only" cards. These seem to be the folks who were cards as an email address w/o first and last name fields. Not only that, I have multiples of the "email only cards" and each one has a different set of mutliple "email only" addresses under it. But, at least one of the "email only cards" just has the desired email w no other info. Can I fix this other than manually?
    I now have a disaster of an Address book.

    ok, I've spent some time doing various scenarios.
    I have managed to replicate one scenario which does as you say.
    If my contact in the address book:
    With name details as Peter Foo
    email address: [email protected]
    where there is an inserted space before the name peter, of course this is not instantly noticeable, but it is as if you hit the space bar just before typing the email address.
    Then when I use the Contacts Sidebar in a Write message, it will add the email address like this:
    Peter Foo <" peter"@somewhere.com>
    which of course in invalid.
    but in the address book, if highlight the contact, in the section below the email address in blue -if I click this to send an email the email address is printed exacly with the space and it will send as if nothing is wrong.
    So i'm asking you to check those email addresses which insert incorrectly via the Contacts sidebar. They only do this for me if there is a hidden inserted space at the start of the email address.

  • Errors when entering responses manually

    I have been encountering an error, when manually entering responses to an existing (and open) Form in Adobe FormCentral.
    We are currently collecting registrations for an annual event, and the majority of people register online (via the form). However, less than a quarter of all of the participants still use snail mail for registration. This is not a problem, it just means we have to enter them manually.
    My coworker has been entering them, and has had a number of issues. She was clicking to 'Add a Row' and then typing the information in. This worked for awhile, but has sinced caused a number of issues. For instance, she will click on the first field and start typing and the information will be visible, but then it will go blank when she clicks to enter the next field. We have tried to 'Clear Formatting' and deleting cell contents, but it just seems like there is something wrong in the program. She has stopped clicking 'Add a Row' and instead has just resorted to hitting return from the last field, which allows her to add a new row, in which she has to clear formatting before it will accept any content being added.
    This adds an extra step, which is slowing down the process considerably.
    In addition, when she is entering in longer information, if she pauses, it will automatically clear the contents of the cell. So, if she starts typing 123 Longwood Blvd, but pauses to double check spelling or the number, it disappears. She is frustrated to say the least! Is there a setting to change how long you can be active in a cell? Is there a field, much like the formula bar in Excel, where you can type the content in instead?
    Is there something we are missing? I did a few searches, and didn't see anyone else with a similar error or issue, so I have decided to start my own. I thought it might be an issue with browser, but that doesn't seem to be the case.
    Any thoughts and potential ways to fix these issues?
    Thank you in advance!

    Sorry about the problem.
    Can you please share the form with me ([email protected]) so I can investigate.
    Also can you tell me what OS/browser and Flash Player version are you using? To check Flash version you can use http://helpx.adobe.com/flash-player/kb/find-version-flash-player.html. If you don't use the latest one, please upgrade to see if helps.
    Is there a setting to change how long you can be active in a cell? Is there a field, much like the formula bar in Excel, where you can type the content in instead?
    No, we don't have such field, only in place editing allowed.
    Thank you,
    Roman

  • Double character input error when entering data in numbers using Bluetooth keyboard.

    Using a bluetooth keyboard (Logitech) sometimes causes a double character input when entering data in numbers.
    For example if wish to enter the number "22" or the word "in" they become "2222" and "iinn". Pressing enter of tab also causes a double jump
    This problem is not always solved by turning keyboard off and on or by closing down and restarting numbers.
    This problem does not occur in any other app.
    I have used 2 different Logitech keyboards (ultra-slim and the recently new folio keyboard) and both caused the same problem.
    The error is sporadic but frequent and has lead to me often having to switch back to touch input.
    Very frustrating considering these excellent keyboards are ideal for using in numbers when working correctly!
    ANy advice would be much appreciated

    Zombie,
    Not much help I'm afraid, but I just saw your post & wanted to let you know that I have the same problem, but for me it manifests itself in many apps, and it happens with the Apple bluetooth keyboard
    . The only thing I've noticed is that it only seems to happen when I first start typing after not using the keyboard for a while (I'm not sure how long a while is, but maybe 30 seconds or so). Then I'll type & the first few letters will be fine, and then one letter double-types, and then it's fine again until I stop using it for whatever the threshold amount of time is. I'm guessing that it has something to do with the iPad's battery management & that it's shutting off the connection to the keyboard or something & once it picks it back up, then it double-types that letter.
    At least in Pages, it isn't as big of a deal because I know it's coming, I can correct it & then type for a long time. In Numbers, my keyboard use is much less consistent, so I need to be more cognisant of it.

  • ISync adds a "-" to contacts with First/Last Name Blank

    Hello, I'm using iSync 2.3 with a Nokia 8800 (S40) and Sonyericsson T610.
    When a contact's name is First name:John Last name:Smith, it syncs properly to my phones as "John Smith".
    With First name: John Smith Last name: empty, it syncs as John-Smith-.
    Same goes with a blank first name. Some of the contacts only have a first name written in, anyone knows how I can get rid of the extra -s?

    I'm not aware of anyone called just "John"! Everybody I know has at least a first name and a last name... therefore that is the data I enter into Address Book and iSync works fine for me and all my Sony Ericsson phones.
    If you don't provide the required data, you can't really expect iSync to work correctly.
    There is a reason for this... its because most phones don't split First and Last Name into two fields like Address Book does. So, if you have a contact named just "John" with no last name, when you sync, how does iSync know whether "John" is a First or Last name?
    To get around this iSync adds a '-' into the blank field, so that when syncing back it knows where to put the data.
    The solution is extremely simple, just provide Address Book with a first and last name (which AFAIK everyone has).

  • Embedded PDF filename = first+last name

    Hello,
    I am currently setting up a website for a sports club and they would like a fillable pdf for online registration that will then be emailed to them upon completion.
    Firstly somehow I need a identifier field I believe if I can use say the first two letters of the first and last name plus the seconds modifier it will be unique. Which they can use as a reference.
    If anyone has any ideas on how to acheive this please let me know =)
    Secondly when the user clicks save or email it would be really handy for the filename to automatically change to the unique identifier.
    Thirdly I'll be embedding this PDF in a joomla article, does anyone have any ideas if I could create a button that would send the pdf as an attachment automatically through joomla when a user presses the submit button in the PDF?
    I have searched all morning (6 hours now) and havn't got far at all, so I decided to come here. Any help is very much appreciated!

    Renaming the file is something that you need to do server-side when you're
    generating the PDF file, before serving it to the user. If the file is not
    generated by a server but is simply offered to the user as a static file on
    the server, then it's not possible.
    I don't know much about Joomla, but I don't think you could achieve this
    with a script from within a PDF, either.

  • Sort order changes when adding a phonetic last name?

    I have my contacts sorted and displayed by first name. If I add a phonetic last name to a contact, it changes the order of that person to the top of list. Why wouldn't it leave them in the first name alphabetic order?

    Ok this is what I'm doing...
    My last name is spelled with "liter."
    Siri pronounces that like "a 2 liter of soda."
    So I've added the phonetic last name field on the contact card to help her pronounce it like "lighter."
    On my contact info,
    First name: Bill
    Last name: Hinderliter
    Phonetic last name: Hinderlighter
    If I delete the phonetic last name field... It sorts the contact perfectly.
    If I add it, the contact is placed on top of all the "B's" in the list.
    On a side note... I found another website with a temporary fix to this problem. The person there says to use the nickname field instead of phonetic field when getting Siri to pronounce things.
    http://apple.stackexchange.com/questions/29210/how-do-i-get-siri-to-pronounce-my -name-correctly
    Thanks again for your time.

  • Inverting first & last names in reports

    Post Author: jweckerly
    CA Forum: Crystal Reports
    Can anyone tell me the syntax for breaking down a string that contains a persons name? We store names by last name first, separated by commas. When I generate a report I would like to reverse them to have the first name before the last name. Thanks

    Post Author: kcheeb
    CA Forum: Crystal Reports
    In a formula field in CR you could do the following. Not 100% sure if I have the InStr functions arguments in the correct order, but you should be able to look that up
    LastName = Left(Name, InStr(',',Name) - 1)
    FirstName = Mid(Name, InStr(',',Name) + 1))
    FirstName + " " + LastName

  • In Infopath - From User Group webservice First & Last Name are not displaying

    Hi, I am working on Internet faced Infopath Sharepoint 2010 web application.In Infopath form we used a User Group web service to retrieve the first and last names when opening the form. In Development environment its working fine (Ex:- http://sharepoint2010dev:45/)
    then we extend the webapplication with domain name in url.(Ex:http://Domainsp:80/) then the first and last names from User Groups is not working.
    Please give your suggestions to resolve this isssue.
    Any help is appreciated..!

    Hi,
    According to your post, my understanding is that the User Group web service not worked when extend the web application with a domain name in URL.
    Did you change the URL to the UserGroup web service in the Data Connection Wizard?
    As you had changed the URL, I think you should change the URL(http://<site>/_vti_bin/UserGroup.asmx), then check whether it works.
    http://blog.ianchivers.com/2011/01/using-sharepoint-usergroup-web-service.html
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • First, Last name fields in Numbers -- Three columns on iWeb page

    I'm new to this (both Numbers and iWeb) and I'm trying to help someone with their page (it's for a local candidate).  They have an excel spreadsheet with names and a bunch of other stuff.  they want to put the list of first and last names on their "supporters" webpage, separated by a space, without having to do it manually -- at this point about 900 such names.
    I can get the names out of Excel and into Numbers, obviously.  And I think I know how to get the list into iWeb, if I can generate it (using an iWeb snippet, which I'd also love help with if anyone here knows THAT as well).
    What I can't seem to do is create a list, in three columns, with First name (single space) last name.  Whatever I put in the formula bar seems not to do anything. And I haven't even BEGUN to figure out how to generate the three-column list.
    Any help would be gratefully appreciated.  As dunce-worthy as possible -- believe me, I won't be offended if anyone talks down to me.

    Hi d,
    I think it's the "three column specification that's throwing me. You might need to clarify that.
    The names are currently entered with First names in one column and Last names in the adjacent column. Here's a way to combine the first and last names into a "full name".
    In the "Full" column, the formula is:
    =B&" "&C
    In Last, First, the formula is:
    =C2&", "&B
    To list the names in a three column table in iWeb, you may need to start with a three column table in Numbers. This one pulls the names from column D (Full) of the table above, and distributes them into three columns. The original table has had four names added, and has been sorted.
    Note that the original table has been named "Data".
    The Data table contains the formula(s) shown above.
    The second table, "Aux", calculates the number of cells needed in each of the three columns so that no column is more than one cell longer than the shortest. Doing this calculation in an auxiliary table greatly simplifies the formulas needed in the final table.
    This table contains a single formula, entered in B2, and filled right to D2. Note that A2 is referenced in the formulas in the final table, "3 Columns". A2 may be empty, contain text, or contain the number zero.
    B2 (and fill right): =QUOTIENT(COUNTA(Data :: $C),3)+IF(MOD(COUNTA(Data :: $C),3)>COLUMN()-2,1,0)
    The third table, "3 Columns" displays the names in three columns.
    It contains a single formula, placed in A1 and filled right to column C and down to row 10.
    3 Columns::A1 (and fill right and down): =IF(ROW()<=Aux::B$2,OFFSET(Data :: $A$1,SUM(Aux::$A$2:A$2,ROW()),3),"")
    Descriptions and further examples for the functions used may be found in the iWork Formulas and Functions User Guide. The guide may be downloaded via the Help menu in Numbers.
    Regards,
    Barry

Maybe you are looking for

  • Movies in Itunes not showing up on Apple TV

    I am finding that some movies which I have added to Itunes and play fine on my Mac, do not appear on my Apple TV.  They are mpeg4 with the H.264 codec, which is what all my videos are.  I have tried rebooting the ATV and also restarting Itunes on my

  • Flushing a SocketChannel before close()

    Hi, I wrote a simple http server using java.nio. I've run into a problem where occasionally, calling close() on the SocketChannel closes the socket prematurely, before all the response bytes have been sent to the client. Is there a way to ensure that

  • Mac OS 9?

    I am saving up to buy a used apple iBook. The one I have my eye on is an iBook G3 for $300. I am used to a new iMac, with Mac OS X.... The software right before Leopard. Anyway, it has Mac OS 9.1. I don't think I can update it anytime soon, (leopard

  • Can you still restore an iPhone 4S to iOS 6?

    I'm trying to restore my AT&T 4S to complete the unlock process, but if I try to do it on iOS 6, it finishes with Error 3194 - the device is not eligible for the requested build.  It suggests upgrading iTunes, and when I do, it tries to force iOS 7 o

  • All things were deleted

    I update my iPhone 4 last night ,in the morning I check my phone and all the contact was deleted!!!! I didn't save any contact on my computer and I don't have a iCloud account ,plsssss help me