My if/else code doesn't work correctly.

If I remove the Scanner function if works. However if I allow user to enter the input, it does not work correct. I can't spot what's wrong. Please help!
import java.util.Scanner;
public class Club{
public static void main( String args[] ) {
String lastName = " ";
Scanner sc=new Scanner(System.in);
//allow user to enter last name.
     System.out.println ("Please enter your last name.");
     sc.nextLine();
//user may join club is lastName is Lim or Tan.
if(lastName=="Lim"||lastName=="Tan") //This is the relational expression
{System.out.println( "You may join the LIM & TAN club as member.");
else
// user may not join club if lastName is not Lim or Tan
{System.out.println( "Sorry");
       System.out.println( "You may not join as member.");
return;
}

I change it to this way, but it still doesnt work...
import java.util.Scanner;
public class Club{
public static void main( String args[] ) {
String lastName = " ";
Scanner sc=new Scanner(System.in);
//allow user to enter last name.
System.out.println ("Please enter your last name.");
sc.nextLine();
//user may join club if lastName is Lim or Tan.
if("Lim".equals (lastName)||"Tan".equals (lastName)) //This is the relational expression
{System.out.println( "You may join the LIM & TAN club as member.");
else
// user may not join club if lastName is not Lim or Tan
{System.out.println( "Sorry");
System.out.println( "You may not join as member.");
return;
}

Similar Messages

  • Servlet (html code doesn't work correctly on IE6)

    Hi, i've a problem with code html on servlet...my page works correctly with firefox but on IE6 i've a lot of bugs about table alignment and CSS looks like not exist . This is code that doesn't work:
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            PrintWriter out = response.getWriter();
            String context = request.getContextPath();
            response.setContentType("text/html");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>RisultatoRicerca Servlet</title>");
            out.println("<link rel='stylesheet' type='text/css' href='"+context+"/css/cd.css'>");
            out.println("<script>");
            out.println("</script>");
            out.println("</head>");
            out.println("<body>");
            DbUtility utility = new DbUtility();
            GestioneCd gestioneCd =new GestioneCd();
            GestioneNoleggio gestioneNoleggio=new GestioneNoleggio();
            Cd cd = newCd();
    cd.setArgomento(request.getParameter("argomento")==null?"":request.getParameter("argomento"));
            cd.setEtichetta(request.getParameter("etichetta")==null?"":request.getParameter("etichetta"));
            cd.setUbicazione(request.getParameter("ubicazione")==null?"":request.getParameter("ubicazione"));
            int valoreRadio=request.getParameter("attivo")==null?0:Integer.parseInt(request.getParameter("attivo"));
            if (valoreRadio==1){
                cd.setAttivo(true);
            }else if (valoreRadio==2){
                cd.setAttivo(false);
            Connection con = null;
             LinkedList cdFromRisultatoRicerca=new LinkedList();
            try{
                con=utility.getConnection();
                cdFromRisultatoRicerca=gestioneCd.getRisultatoRicercaCd(con, cd,valoreRadio);
                ListIterator iterator = cdFromRisultatoRicerca.listIterator();
                int id=0;
                String argomento="";
                String etichetta="";
                String ubicazione="";
                out.println("<form name='visualizza' method='post'");
                out.println("<table align='center'>");  // NOT WORKS , table alignment not respected on IE6
                out.println("<tr><td colspan='9' align='center'></td></tr>");
                out.println("<tr><td colspan='9' align=center class='titolo'>Risultato ricerca</td></tr>");
                out.println("<tr>");
                out.println("   <td align='left' class='titolo'>Id</td>");
                out.println("   <td align='left' class='titolo'>Argomento</td>");
                out.println("   <td align='left' class='titolo'>Etichetta</td>");
                out.println("   <td align='left' class='titolo'>Ubicazione</td>");
                out.println("   <td align='center' class='titolo'>N.copie</td>");
                out.println("   <td align='center' class='titolo'>Disponibili</td>");
                out.println("   <td align='left' class='titolo'>Attivo</td>");
                out.println("   <td class='titolo'> </td>");
                out.println("   <td class='titolo'> </td>");
                out.println("</tr>");
                out.println("<tr>");
                out.println("   <td colspan='7' align='center'>");
                out.println("       <HR width='100%'>");
                out.println("   </td>");
                out.println("   <td> </td>");
                out.println("   <td> </td>");
                out.println("</tr>");
                int copie=0;
                while (iterator.hasNext()){
                    cd=(Cd)iterator.next();
                    out.println("<tr>"); // NOT WORKS, on IE6 lines appears not in a table
                    out.println("   <td>"+cd.getId()+"</td>");
                    out.println("   <td>"+cd.getArgomento()+"</td>");
                    out.println("   <td>"+cd.getEtichetta()+"</td>");
                    out.println("   <td>"+cd.getUbicazione()+"</td>");
                    out.println("   <td align='center'>"+cd.getCopie()+"</td>");
                    int copieNoleggiate=gestioneNoleggio.getCopieNoleggiate(con,cd);
                    int copieDisponibili=(cd.getCopie())-(copieNoleggiate);
                    out.println("   <td align='center'>"+copieDisponibili+"</td>");
                    out.println("   <td align='center'>");
                    if (cd.isAttivo()==true){
                        out.println("<img src="+context+"/immagini/pulsanteverde2.gif>");
                    }else{
                        out.println("<img src="+context+"/immagini/pulsanterosso2.gif>");
                    out.println("   </td>");
                    out.println("   <td>");
                    out.println("       <a href='javascript:;' onclick=\"javascript:window.open('"+context+"/servlet/ModificaCd?id="+cd.getId()+"','Modifica','width=500,height=300,top=200,left=300');\" target='main'>Modifica</a>");
                    out.println("   </td>");
                    if (cd.isAttivo()){
                        out.println("   <td>");
                        out.println("       <a href='javascript:;' onclick=\"javascript:window.open('"+context+"/servlet/ConfermaDisattiva?id="+cd.getId()+"','Disattiva','width=300,height=70,top=250,left=350');\" target='main'>Disattiva</a>");
                        out.println("   </td>");
                    }else{
                        out.println("   <td>");
                        out.println("       <a href='javascript:;' onclick=\"javascript:window.open('"+context+"/servlet/ConfermaAttiva?id="+cd.getId()+"','Attiva','width=300,height=70,top=250,left=350');\" target='main'>Attiva</a>");
                        out.println("   </td>");
                    out.println("</tr>");
                    out.println("<tr>");
                    out.println("   <td colspan='7' align='center'>");
                    out.println("       <HR width='100%'>");
                    out.println("   </td>");
                    out.println("   <td> </td>");
                    out.println("   <td> </td>");
                    out.println("</tr>");
                out.println("<tr>");
                out.println("   <td colspan='9' align='center'>");
                out.println("       <a href='"+context+"/jsp/index.jsp' target='main'>Torna Home</a>");
                out.println("   </td>");
                out.println("</tr>");
                out.println("</table>");
                out.println("</form>");
            }catch (SQLException e){
                out.println(e.getMessage());
                out.println(e.getSQLState());
            }finally{
                try {utility.closeConnection(con);} catch (Exception e) {con=null;}
            out.println("</body>");
            out.println("</html>");
            out.close();
        }And this is CSS :
    BODY {
            background : #CCCCCC ;
            color : #000000 ;
            font-family  : sans-serif ;
            font-size : 13px ;
    A {
            color : #D2691E ;
            font-weight : bold ;
            font-family : sans-serif ;
            font-size : 12px ;
            text-decoration : none ;
    TABLE {
            background : #CCCCCC ;
            color : #000000 ;
            font-family : sans-serif ;
            font-size : 13px ;
            border : 1px ;
    .titolo {
            background-color : #CCCCFF ;
            font-family : sans-serif ;
            color : #000000 ;
            font-size : 13px ;
            font-style : normal ;
            font-weight : bold ;
    }Thx for your attenction :D

    out.println("<form name='visualizza'
    'visualizza' method='post'");
    out.println("<table align='center'>");
    'center'>"); // NOT WORKS , table alignment not
    respected on IE6You're missing a > at the end of the form start tag.

  • AddChild doesn't work correctly in 11.9

    comparing the two releases listed below, somehow my Flash program doesn't work correctly on the latest version anymore, nothing was changed in my program but after upgrading to the latest Flash Player, it doesn't work properly anymore, specifically, the items I add through the addChild method doesn't appear properly, was there any changes in between these versions that could have affected the addChild behavior? I'm testing with Windows  7 IE debug version and I see no script errors
    Released 10/8/2013) Flash Player 11.9.900.117 (156.2 MB)
    (Released 9/24/2013) Flash Player 11.8.800.175 (Win IE only) (50 MB)

    Could you please open a new bug report on this over at bugbase.adobe.com?  When adding the bug, please include sample code, test url or a test swf so we can quickly test this out internally.  If you'd like to keep this private, feel free to email the attachment to me directly ([email protected]). 
    Once added, please post back with the bug URL and I'll investigate internally.
     

  • After upgrade my iphone 4 to IOS6, sound doesn't work correctly

    After upgrade my iphone 4 to IOS6, sound doesn't work correctly.
    During a phone call, there is no sound. But if I turn on the speaker, there is sound. itune works fine since it's on the speaker.

    Dear All
    i have done the same activity ( buy a new iphone 4 -> upgrade to ios5 - > configure email) with success-
    than when i start to move the contacts from old mobile to iphone (using the microsim) i receive the same crash
    in disgnosis e use i saw 2 dump with this title 'latestCrash-Preferences.plist and LatestCrash.plist. in each file the date is the same and i read:
    Exception Tyle: EXC_CRASH (SIGABRT)
    Exception code: 0x00000000, 0x00000000
    Chrashed Thread: 6
    in thread 6: name: Dispatch queue:
    com.apple.addressBookUI.ContactsSettingPlugin
    and thaan a lot of data.
    Have you any idea?
    thank in advance
    Fabio

  • How to use documentbeforesaved method? And why my code doesn't work in template files?

    Can someone help me with these two codes?
    ----Beginning of code 1-------------
    Private WithEvents App As Word.Application
    Private Sub Document_Open()
    Set App = Word.Application
    End Sub
    Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox("BeforeSave")
    End Sub
    --------------End of the code----------------
    Beginning of code 2--------------- Code 2 is from https://msdn.microsoft.com/en-us/library/office/ff838299(v=office.15).aspx
    Public WithEvents appWord as Word.Application 
    Private Sub appWord_DocumentBeforeSave _ 
     (ByVal Doc As Document, _ 
     SaveAsUI As Boolean, _ 
     Cancel As Boolean) 
     Dim intResponse As Integer 
    Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox("BeforeSave")
    End Sub
    In the first code, they have:
    Private Sub Document_Open()
    Set App = Word.Application
    End Sub
     I test these two codes in "This document" object, and I find out the first code works but the second code are not!
    Why second code doesn't work?
    Extra question: I am using microsoft 2013. I insert this code into a macro-enabled template. But when I am about to save my file I am expecting these code works. However, they didn't work!
    Thank you for solving these problem for me!

    Hello,
    Please note that the code snippet 2 in your post is different from the code snippet in the MSDN document. Also please read the comments of the MSDN code sample:
    This example prompts the user for a   yes or no response before saving any document.
    This code must be placed in a   class module, and an instance of the class must be correctly initialized to   see this example work; see
    Using Events with the Application Object for   directions on how to accomplish this.
    Public WithEvents appWord   as Word.Application
    Private Sub   appWord_DocumentBeforeSave _
     (ByVal Doc As Document, _
     SaveAsUI As Boolean, _
     Cancel As Boolean)
     Dim intResponse As Integer
     intResponse = MsgBox("Do you really   want to " _
     & "save the document?", _
     vbYesNo)
     If intResponse = vbNo Then Cancel = True
    End Sub
    So the problem in your code snippet 2 is that you didn't put it into a class module and initialize the class module. If you just put it into ThisDocument, you have to initialize the word application object.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Game Center doesn't work correctly

    Game Center on iPod Touch 2nd Gen doesn't work correctly under iOS 4.2.1
    It shows wrong language (Englist but not my native language. My region setting is right and the system language right too.)
    Besides, the "Games" page only has a button "Find Game Center Games", while it should show my Game Center Games.
    The Friends page shows all my friends. But when I press a friend the sub page doesn't show the game my friend and I have in common.
    I've restored my device several times, but it didn't help.
    How to solve it?

    I've had exactly the same problem on my 2nd gen since early May when it just stopped working out of the blue.
    There are a few threads here on the subject. I believe that every 2nd gen is affected as I've yet to hear a 2nd gen owner say that theirs works.
    Other than waiting for Apple to fix it I don't think there is a solution.

  • IPhoto doesn`t work correctly with german "umlaut" (ä,ö,ü) in keywords

    iPhoto doesn`t work correctly with german "umlaut" (ä,ö,ü) in keywords. They get to ä̈,ö̈, ü̈ when I write the keyword a second time. Can anybody tell me why. Thank you. Heinz

    It apparently does not like non-standard English characters - use A-Z and 0-9 adn you should be OK
    report to Apple - iPhoto menu ==> provide iPhoto feedback
    LN

  • Translation from CS5 to Cloud doesn't  work correct, navi and linked images are broken.

    Translation from CS5 to Cloud doesn't  work correct, <navi> and linked images are broken.
    The data of CS5 was created at another PC. I installed Cloud version into two different PC. One has had the site data since dreamweaver CS5 and it works correct in Cloud version. Another PC got the site data from remote server and it doesn't work correct. <navi> and linked image are broken.

    Another PC got the site data from remote server and it doesn't work correct. <navi> and linked image are broken.
    This implies your site is not properly defined in DW.  Go to Site > Manage Sites.
    Or simply go to your other installation of DW and export the site definition file from Manage Sites.
    Save it to a flash stick or other removable drive.  Then import the STE file into your 2nd installation of  DW.
    Nancy O.

  • ITunes 10.4 full screen with Win7-64bit doesn't work correctly.

    iTunes 10.4 full screen with Win7-64 doesn't work correctly. I have the Windows taskbar on the left side of my screen. Maximized iTunes is panned to the left.

    Same issue here. When the Windows taskbar is position on the top of the screen and then the iTunes windows is maximised, it's position is as if the Windows taskbar is at the bottom of the screen so the top of the iTunes window sits under the taskbar.
    For those wanting a workaround, hold shift and right click the iTunes icon in the taskbar/quick launch bar and click restore, at least then you can adjust it to be full screen manually.
    System:
    Windows 7 Ultimate x64
    iTunes 10.4
    ATI 5750 video card

  • [svn] 4028: Bug: Draining of buffered messages doesn' t work correctly with long-polling.

    Revision: 4028
    Author: [email protected]
    Date: 2008-11-06 09:04:26 -0800 (Thu, 06 Nov 2008)
    Log Message:
    Bug: Draining of buffered messages doesn't work correctly with long-polling.
    QA: Yes - please make sure both nio and regular long-polling channels work with throttling.
    Doc: No
    Checkintests: Pass.
    Details: Made sure that buffered messages are drained properly with all polling channels (polling, long-polling, and nio-long-polling).
    Modified Paths:
    blazeds/trunk/modules/core/src/flex/messaging/client/FlexClient.java

    Sounds like you've probably already looked but the CUPS article in the wiki led me through setting up a printer without any problems.  http://wiki.archlinux.org/index.php/CUPS
    The first section describes how to troubleshoot CUPS and printing problems.
    I've also found a few other posts and links that may help.
    http://hplipopensource.com/hplip-web/mo … eries.html
    http://ubuntuforums.org/showthread.php?t=419163
    Hope this helps!

  • ISF/javascript code doesn't work for non-English RequestCenter proile

    ISF/javascript code doesn't work for non-English RequestCenter proile
    Hello,
    I am not sure if i posted the same question before also. We have some customers who have set thier language profile in newScale requestcenter to French. However, all the javascript customizations configured on the service forms do not function for 'French' as a Langauge preference. Has anyone encountered the similar issue before and can anyone please suggest a solution for it?
    Thanks,
    Mihir

    we had a similar issue a while back where the Approval button was not working in Spanish, needed a fix from nS for it
    The way to fix this would be to locate the language XML file, override the French caption with Submit and on onLoad write a global JS that would write the button label again (not so sure about this)
    But really its an major defect and they should be able to fix it.

  • How can I avoid duplicates on contacts and how do I get contacts created on iPhone/ipad synchronized on my mac? so far it doesn't work correctly, just sometimes. same for icalendar

    how can I avoid duplicates on contacts and how do I get contacts created on iPhone/ipad synchronized on my mac? so far it doesn't work correctly, just sometimes. same for icalendar

    On your Mac, for duplicates, switching Contacts off then back on in System Preferences > iCloud may prevent duplicates.
    On the iPhone / iPad tap Settings > iCloud. Make sure Contacts and Calendars are swtiched on.
    Try restarting your Mac and your iOS devices when items won't sync as they should.
    To restart an iOS device:  Hold the On/Off Sleep/Wake button down until the red slider appears. Slide your finger across the slider to turn off iPhone. To turn iPhone back on, press and hold the On/Off Sleep/Wake button until the Apple logo appears.

  • ASR1002 - For DNS it seems that NAT doesn't work correctly

    Hi Folks,
    For DNS it seems that NAT doesn't work correctly
    The ASR 1002 works as a NAT-Router. But for DNS it seems that NAT doesn't work correctly.
    All DNS packets with a frame size greater than 512byte are not processed (they donїt arrive at the DNS Server), but we can't verify if they are dropped or just not processed.

    Sorry guys its everytime*

  • Code Doesn't work although it works on DEV

    hello evey body
    some functions and codes doesn't work on application server But it works on developer ??!!
    as i have code to export data from oracle to excell . it works from developer but it doesn't from application server
    this is my code in the link
    http://www.4shared.com/document/7wTQrK1-/Excell_Rep.html
    does Application Server didn't contain this packages ?
    or what ??

    Hi dorpfeld,
    Please check the KB : http://helpx.adobe.com/creative-suite/kb/error-serial-number-valid-product.html
    I would strongly recommend that you work directly with our support team for serial number issues.
    You can reach our chat support for serial number issues at : http://adobe.ly/1aYjbSC
    Regards,
    Rave

  • The ussd code doesn't work on my iphon since i update to ios 7.0.3 what can i do for this problem?

    the ussd code doesn't work on my iphon since i update to ios 7.0.3 what can i do for this problem?

    Maybe
    SOLUTION: circle with red square Some Music Won't Play After...: Apple Support Communities

Maybe you are looking for

  • The Thunderbolt to Firewire 800 cable?

    I have a JVC digital video camera, and have lost some of the cables. Will a Thunderbolt to Firewire 800 cable connected with a Firewire 800 - Firewire 400 cable (same as ieee1394?) transfer the videos to my MacBook Air?

  • LSO - impart qualification with quantity scale

    Hi experts, I have a problem here that I'd like to share with you. We are building a qualification and training catalogs for LSO, and one of the areas would like that a group of trainings summed would impart one qualification. The problem is that the

  • Lenovo G550 DVD writer problem.

    Heya...i'v a Lenovo G550 with Windows XP SP3. The problem here is that the DVD reads all the DVDs but does not write any. It doesnt even give an error for not writing. I have Nero 9 and when i try to burn a DVD with that it shows burn process started

  • Trying to install Sims 3 on my mac mini and it says it will 260 minutes

    Running 10.5.7 this is the second install that has taken hours to complete. my MM is brand new 2ghz 4gig ram 100gig hd. I installed Sims3 on my MacBook pro and my daughters Macbook and it only took 19 minutes. any ideas?

  • Installation of elements 12 and premiere elements 12.

    I am about to buy Elements 12 and Premiere 12 as a package. I plan to install on my main desktop. I would like to do a second install of each of the Elements and Premiere Elements on two different computers which i own. In other words, a second insta