Why program is giving trouble

error which am getting is
found : int
required: java.lang.String
String noStr =System.in.read();
^
Ass1.java:31: operator || cannot be applied to java.lang.String,java.lang.String
if(op.equalsIgnoreCase("T" || "t"))
^
Note: Ass1.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors
for code
import java.util.Random;
import java.io.*;
import java.util.Scanner;
class Ass1
     public static void main(String args[]) throws IOException
          int arr [], i, j, count=0, no ;
          System.out.println("HIT3037 Assignment 1 Sudoku");
        System.out.println("Author :Ameya Agashe Id:5398541");
          System.out.println("What option?");
          System.out.println("\t G - Generate sudoku");
          System.out.println("\t T - Test solution");
          System.out.println("\t Select one option:");
          Scanner  os= new Scanner(System.in);
          String  op = os.nextLine();
          if(     op.equalsIgnoreCase("G"||"g"))
               System.out.println("Generate Sudoku");
               System.out.println("How many numbers to generate , plz g
               String noStr =System.in.read();
               no =Integer.parseInt(noStr);
               System.out.println("The no entered was" + no);
          else
          if(op.equalsIgnoreCase("T" || "t"))
                         System.out.println(" Test the Sudoku");
                         System.out.println("Please enter the file name")
                         Scanner of=new Scanner(System.in);
                         String fn= of.nextLine();
                         System.out.println("The Name of file entered by
                              //     fn = fn.trim();          
                    String line;      String[] full=new String[10];
                         FileInputStream fis=new FileInputStream(fn);
                    DataInputStream input= new DataInputStream(fis);     
                         while((line= input.readLine())!=null)
                              System.out.println(line);
                              count++;
                         full[count]=line;
}

yeah what if user gives input as "t" instead of "t"
so i made use of orWhat do you think equalsIgnoreCase is for? "T".equalsIgnoreCase("t") returns true
same applies to t also and the logic for conversion
from string to integer seems okObviously it's not okay.
but still why
compiler gives error as i am taking input in string
format and trying to change string to integerThat's why. You can't do int i = "5"; Strings are not ints and vice versa. Integer.parseInt is how you turn a String into an int.
But you probably have a different problem. It's not likely you want to use the read() method. You should use a BufferedReader and readLine, or Scanner.nextInt.
>
where i need to rectify my code if u run this code
for otion g it works but not for t ,this is recent
development

Similar Messages

  • I just tried to download sons of anarchy season 6 and it went into purchases then just disappeared... Why is it giving me trouble I have a cc on file

    I just tried to download sons of anarchy season 6 and it went into purchases then just disappeared... Why is it giving me trouble I have a cc on file

    Mavericks - reverting back from:
    https://discussions.apple.com/docs/DOC-6162

  • Why am i having trouble updating itunes  on my windows 7 (64 bit) computer?

    Why am I having trouble updating itunes on my windows 7 (64 bit) computer?

    Doug
    Thanks for the update.
    nothing is getting installed, copied or otherwise loaded onto my computer....first the program starts to load, then it asks for my serial number, then it goes out and seems to check the serial number then it says it can't be installed then it erases everything it just spent 10 minutes loading.
    In view of the above and your prior descriptions, have you tried alternative installation files?
    If you want to give a look to that approach, please download and install the tryout files for Premiere Elements 9 from the following web site and then insert your purchased serial number into them during installation.
    With this route, you need to carefully carry out the web site's "Note: Very Important Instructions" in order to avoid an Access Denied message.
    Photoshop Elements 9 / Premiere Elements 9 Direct Download Links | ProDesignTools
    Back to my questions from post 3
    Are you getting any Shared Technologies error message any where in the installation process that is failing?
    If you follow the following path, do you find an OOBE Folder?
    Local Disk C
    Program Files (x86)
    Common Files Folder
    Adobe
    and in the Adobe Folder should be the OOBE Folder which you rename from OOBE to OLDOOBE to disable it.
    When you are forced into a roll back for whatever installation has taken place, do you ever see a message about Shared Technologies?
    And, whether or not the program installs to any extent, does your computer have the OOBE Folder? If so, then please rename it to disable it before
    you try for another 9 install.
    Looking forward to your results.
    ATR
    Add On....Please remind me....since you purchased Premiere Elements 9, have you ever installed and used it successfully on any computer?

  • Trade-in program is giving Verizon a Customer Service a bad Reputation

    The trade-in.vzw.com program is giving Verizon a huge negative customer service problem. I was concerned when I submitted my mint condition iphone 4 in the flimsy envelope they provided. And sure enough, it has been a month today and the check status website still has "not received" it according to the  link. They have it, post office did their job. And those phone calls to 877-247-3846 - wow - what a colossal waste of time for absolutely no information, that's if you do actually get a person who won't give their name and will hang up on you!  THIS IS NOT THE EXCELLENT CUSTOMER SERVICE I HAVE HAD AT VERIZON FOR 12+ YEARS!
    Then I come here and read they are shorting their customers in the trade-in amounts - wow again!  Really? It's a sales Promotion and they short their customers amounts like $166 of a $200 promotional trade-in value. Unbelievable!
    They haven't done that to me - yet. Because after a MONTH they are saying they still have not received my iphone.  I don't buy the due to the heavy volume we don't have time to take care of business lame excuse, get some help and get it done! By reading other customer posts they have been using this excuse for some time, well before the Iphone 6 launch.  Bad planning and simply not good business on Verizon's part.
    So I'll wait. Don't have much choice. And I don't have time to take the battle to the media, but some of you who have been so wrongly treated should.
    Damage to Verizon customer service has been done, and continues with each passing day.  My question is 'Has anyone had a good customer service experience with the Verizon Trade-in program?'

        OptionsTrader,
    So sorry to see the trouble you have had with the Trade-In program. We want our customers to have a great customer experience with anyone we partner with. Our Device Recycling Support Team can also be reached at 877-835-2024 or by going to http://bit.ly/GGnDDC and clicking on Contact Us. Our apologies for any difficulties getting assistance.
    BrianP_VZW
    Follow Us on Twitter @VZWSupport

  • My iTunes program is giving me a message that says, "Runtime error" and wont open iTunes. How do I fix this?

    My iTunes program is giving me a message that says, "Runtime error" and wont open iTunes. How do I fix this?

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • Why am I having trouble importing vCards? I follow the Help Center instructions by dragging and dropping, but some don't sync into the cloud. And why can't I drag multiple vCards? I have over 4,000. Please tell me I don't have to do one at a time?

    Why am I having trouble importing vCards? I follow the Help Center instructions by dragging and dropping, but some don't sync into the cloud. And why can't I drag multiple vCards? I have over 4,000. Please tell me I don't have to do one at a time?

    carolinechx wrote:
    i know the description may be a little bit too confusing
    Mostly because you are not using any capital letters or paragraph returns and your post is difficult to read.

  • I've just installed Mountain Lion 10.8.5, but now the CS programs are giving me a licensing error.

    I've just installed Mountain Lion 10.8.5, but now the CS4 and CS5 programs are giving me a licensing error. I've restarted. Uninstalled, reinstalled. And still, they don't work. I need to stay at 10.8.5 and not go to Maverick, per a client's needs at this time. Help!

    I've also tried this...that I found in another discussion...also did not work.
    Solution 1: Delete the FlexNet Publisher preferences folder
    -  Quit all Adobe applications.
    -  On your startup disk, locate and delete the following folder:
    [hard drive]/Library/Preferences/FlexNet Publisher/ 

  • Why not nokia giving belle or other better update ...

    why not nokia giving belle or any other update for 5233, 5235, 5230
    Many of indians nokia phone user has disspointed after seeing android, and belle user interfence for other phones and not for nokia 5233,35,30 phones . Many of nokia users disspointed after that many of nokia users moving to android and other phons and not for nokia after that,
    Why not nokia giving any update hor these phones ..
    Solved!
    Go to Solution.

    The devices you mentioned are symbian S60V5. These cannot be upgraded to Nokia belle or such. They have hardware limitations.
    In Love With My C6-01:Now running on Nokia Belle!

  • Why java is giving 'attempting to assign weaker access privileges'  error?

    Can some one can tell me why java is giving 'attempting to assign weaker access privileges' compile error while compiling Abhishekchild.java ?
    The two classes is :
    public class  Abhishek {
           void asd()
         System.out.println("hello");
              static String a;
              public static void main (String st[])
    public class  Abhishekchild extends Abhishek {
         private  void asd()
         System.out.println("hello");
              static String a;
              public static void main (String st[])
    }In my opinion, java compiler is showing the error , as method asd has public visibility in Abhishek. java so
    (i)it should be visble to all sub classes of Abhishek.java.
    But if we override this function in Abhishekchild.java, and change the visibility to private then it will not be available for child of Abhishekchild.java. But these children are also children of Abhishek.java*, but this violates rule (i).*
    So java shows a compilation error.

    public class Parent {
         public void asd() {
              System.out.println("Hello");
    class Child extends Parent {
         public void asd() {
              System.out.println("Hello from child");
         public static void main(String st[]) {
              Parent parentReference = new Child();
              // The reference 'parentReference' knows about Parent.
              // Parent has a public method asd, so below code looks ok.
              // But if child could set the method to private,
              // invoking the code below, would hit the object Child,
              // where asd() is not accessible - and everything fails.
              // Note - the compile visibility is checked according to
              // the reference, not the object itself.
              parentReference.asd();
    }See my comments in the code.
    - Roy

  • Photoshop 7.0 was giving trouble. I tried to delete and reinstall. It deleted but I can't reinstall

    Photoshop 7.0 was giving trouble. I tried to delete and reinstall. It deleted but I can't reinstall

    Nobody can tell you anything without system info and an exact description of the problem.
    Mylenium

  • Why am I having trouble uploading photos from iPhoto on mac after update

    Why am I having trouble uploading photos from iPhoto on mac after update

    Good day!
    What does this have to do with Photoshop?
    Wouldn’t the question better be asked on a Macintosh Forum?
    Regards,
    Pfaffenbichler

  • Why am i having trouble installing adobe flash player i have 32 bit on my laptop

    why am i having trouble downloading adobe flash player my laptop is 32 bit i was allowed to watch videos on the internet last week but now i get error messages that i have to download adobe flash player

    Then try left-clicking on it, and use the Enable button at the bottom right of the Add-ons panel.

  • HT1688 Why am I having trouble updating the new ios7.0.4 to my iphone 4s?

    Why am I having trouble updating the new ios7.0.4 to my iPhone 4s?

    There is no update for iOS 7.0.4.

  • Why am I having trouble running Adobe Flash Player 11 on my 2011 Macbook Air? I've downloaded and installed it repeatedly; yet when I try to open certain images online or play certain Youtube segments, I get the message, "You must have Adobe Flash 11..."

    Why am I having trouble running Adobe Flash Player 11 on my 2011 Macbook Air? I've downloaded and installed it repeatedly; yet when I try to open certain images online or play certain Youtube segments, I get the message, "You must have Adobe Flash 11..."  My computer tells me it is installed and running.

    If you're sure you've installed the latest version of Flash, take each of the following steps that you haven't already tried. After each step, relaunch Safari and test. For a "missing plug-in" error, start with Step 5.
    1. If you're only having trouble with YouTube videos, sign in to your YouTube account and load this page. You may see a link with the text "Leave the HTML5 Trial." If so, click that link.
    2. If you're getting a "blocked plug-in" error, then from the menu bar select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Check Now. Quit and relaunch your browser.
    3. Triple-click the line below to select it:
    /Library/Internet Plug-Ins
    Right-click or control-click the highlighted text and select
    Services ▹ Open
    from the contextual menu. A folder should open. Delete the following item, or anything with a similar name, if present:
    Flash Player (failing).plugin  
    You may be prompted for your login password.
    4. Re-download and reinstall Flash. Download it from this page:
    Adobe - Install Adobe Flash Player
    Never download a Flash update from anywhere else.
    5. If you get a "missing plug-in" error, select
    Safari ▹ Preferences... ▹ Security
    from the Safari menu bar and check the box marked Enable plug-ins.
    6. Select
    Safari ▹ Preferences... ▹ Extensions
    from the Safari menu bar. If any extensions are installed, disable them.
    7. In the Safari preference window, select
    Privacy ▹ Remove All Website Data
    Close the window. Then select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Delete All. Close the preference pane.

  • I have an ipod touch 4th gen ... love it .. but only one problem... the headphone jack is giving trouble.... help me plz!!

    i have an ipod touch 4th gen ... love it .. but only one problem... the headphone jack is giving trouble.... help me plz!!

    Have you verified that it is the headphone jack that is the problem by trying opther sets of headphones?
    Have you tried cleaning the jack by using a QTip or similar ite?
    If you confirmed that the headphone jack is the problem Apple will ony exchange the iPod for $99, $149 or $1999 depending upon the capacity.
    A third-party place like the following is less expensive. Google for other places.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens

Maybe you are looking for

  • IPad reboots itself and thinks it needs to be restored as an iPhone

    Help! My iPad keeps rebooting itself every few minutes (if I am trying to use it). It tells me that the iPhone can't make or receive calls(?)and that I need to restore from iTunes at www.apple.com/support. Obviously the iPad can't make or receive cal

  • Assign Application Roles

    Hi All, I am new to SOA and I want to know how to assign application roles (Not global roles) through EM Console. As, I am unable to assign the roles through  BPM workspace. I can go to the administrator tab and assign the roles to me. But in the tas

  • How to show negative(-) as parentheses

    Hi, Does anybody know how to display negative sign as parentheses in ABAP report (simple list or ALV). For eg. Standard SAP shows -100.00 as 100.00-, but user wants to display it as (100.00). Thanks Anil

  • How to summarize on multiple cross tabs

    Dear Sirs/Madams I have created a report in which I am using 2 queries. For each query I have created a crosstab which looks like this: Crosstab Query 1                      Jan 2010      Feb 2010 Keyfigure 1       X1             X2 Keyfigure 2      

  • MessagingException "Unknown SMTP host"

    Hi I am using JavaMail to send out emails from an ecommerce application. We are now deploying the application and are getting the following message.... nested exception is: class javax.mail.MessagingException: Unknown SMTP host: smtp.thehost.com ; ne