Very simple program error (help)

Dear group,
Just wanted to get a number from sdtin and print it. The program shows a compiler error. Help.
import java.io.*;
class keys
     public static void main(String args[])
          int a,b;
          System.out.println("enter a number");
          try
               a = System.in.read(b);
               System.out.write(a);
          catch(IOException e){
`               System.out.print("Sorry. can't print.");
}

error:
symbol:cannot resolve sysbol
location: class java.io.ImputStream
          a = System.in.read(b);but the same function works in this program.
class keys{
  public static void main (String args[])
      byte name[] = new byte[100];
      int n_read = 0;
      System.out.println("What is your name?");
      try {
        n_read = System.in.read(name);
        System.out.print("Hello ");
        System.out.write(name,0,n_read);
      catch (IOException e) {
        System.out.print("Sorry.  can't catch your name.");
}

Similar Messages

  • Very Simple Problem-- Need help in method selection process

    Hello,
    It's difficult to explain the background of the program I am making-- but I am stuck at a very simple problem, that I can only solve with a very long block of if statements:
    I have 3 possible numbers-- 1, 2, or 3.
    Imagine two numbers are already taken-- say 1 and 2. I want a variable to set itself to the number that's not taken (3).
    So, again: If two numbers were taken say 2 or 3-- I want the variable to be sent to the other one that isn't taken-- 1.
    Thank you for your help,
    Evan.

    Actually, I'll just tell you the context of the program-- here is what I have so far:
    This program is meant to simulate Monty Hall Problem:
    http://en.wikipedia.org/wiki/Monty_Hall_problem
    The program sets up an array of three possible values. Each one of those values represents a door with either a goat or a car behind it. It then randomly sets one of those values to 1 (in order to represent a car as per the Monty Hall problem), and 0's represent goats.
    The user, which is simulated by the program (does not involve actual interaction), chooses a door initially.
    The game show hosts then reveals a door that is not the users initial choice, but IS a goat ( an array value of 0).
    For example if the array was [0][0][1]
    The user could pick door one (array position 0). Which is a goat.
    The game show host then reveals a goat that is not the users choice-- which would be array position 1.
    After the game show host reveals the goat-- I want the user to always switch his decision to the only other remaining door that was not his first choice.
    Then I wanted the computer to test to see if his final choice is the one with a car. And to tally up the amount of times he got it right.
    --Sorry that was long winded:
    import TerminalIO.*;//imports TerminalIO package for system.out.println
    import java.util.*;//import java.util for random
    public class Monty_Problem
         int doors[]= {0,0,0};
         Random rand= new Random();
         double wins,totals=0;
         public void carAssignment()
              int car_door= rand.nextInt(3);
              doors[car_door]=1;
         public int judgesChoice(int judgeDoor, int initialChoice)
              if(judgeDoor != initialChoice && doors[judgeDoor]!=1)
                   return judgeDoor;
              else
                   return judgesChoice(rand.nextInt(3), initialChoice); //infinite loop right here that I cannot remedy.  I want the program to have the judge pick a location that is not occupied by a  '1' and is not the user's choice. 
         public void gamePlaySwitches()
              int initialChoice= rand.nextInt(3);
              int judgeDoor = 0;
              int secondChoice= 0;
              judgeDoor= judgesChoice(rand.nextInt(3), initialChoice);
              //This part is meant to have the user switch choices from his initial choice
                   // to the only other choice that hasn't been revealed by the judge. 
              while(secondChoice == initialChoice || secondChoice== judgeDoor)
                   secondChoice++;
              if(doors[secondChoice]==1)
                   wins++;
                   totals++;
              else
                   totals++;          
         public static void main(String [] args)//creates the main menu
              Monty_Problem a= new Monty_Problem();
              int games=0;
              while(games!=100)
                        a.carAssignment();
                        a.gamePlaySwitches();
                        games++;
              System.out.println(a.wins/a.totals);
    }Edited by: EvanD on Jan 11, 2008 4:17 PM

  • 8.0 applicatio​n builder problem- very simple programs will not install on non LV machine

    Newbie at this...
    1.  Created a simple project (just math) in LV 8.0
    2.  Did the build
    3.  Built an installer but Deselected  RTE installer as I told my customer to download LV RTE 8.0
    4.  The installer put everything into a file folder called VOLUME... (?)
    5.  Copied VOLUME over to non LV machine that had LV 8.0 RTE downloaded and installed.
    6.  Ran ithe NI nstaller on non LV machine.  Ran Ok.
    7.  However,  no files were installed (checked the PROGRAMS directory).
    This is a REAL simple program.  Can anyone point me to some simple/stupid thing I did wrong?
    frustrated in San Diego....
    John

    John:
    Looking at all your steps, it seems like you are doing all the right things and in the right order too. Couple of things that you may try:
    1. Make sure that in your installer properties, you specify "ProgramsFileFolder" in the Source Files tab if you want your installer files to be  
        placed under "...\Programs\" (Please take a look at the attached screenshot)
    2. Try building an executable and make sure that you can run on the customer's computer (since it already has the LabVIEW Run Time Engine)
    Let me know what you find.
    Regards,
    Rudi N.
    Attachments:
    Installer.JPG ‏52 KB

  • Help with Forte: very simple question, please help!

    I recently downloaded the community version of Forte (Sun One) but can't seem to get any new empty class programs to execute properly. I know something is probably not set up right, which is why I really need a little help to get started. Regardless of the code I try to execute, the output error is always:
    "java.lang.NoClassDefFoundError: (name of program)
    Exception in thread "main" "
    Please let me know what I'm not doing right. I would really appreciate anybody's thoughts on this problem because I would love to get Forte working so I can start learning Java. Thanks for your input!

    I would tell you that Forte is not a tool for the beginner. you should look at something simpler. Forte is a fully integrated development environment. I would look at a simple editor like emacs, available at gnu.org. The commands of this editor are quite difficult to get use to.
    As for setting the class varialbe. It depends on the O/s that you are using. win98/me is different than NT/xp. Need to know one or the other before explaining.
    email me if you have question. email address is in my profile.

  • Very simple Programming software for OS X Lion.

    I'm basically new to Mac and to OS X Lion, so be easy with me if my questions are rather simple than what i'm thinking. I recentely purchased a Macbook, switching from windows pc after many years of using it. My new Macbook pro came with OS X Lion and with several awesome software preinstalled, iLife etc... amount them was one called iWeb which is a very interesting software to build web site, back to the time when i was using windows, i was using dreamweaver to build amature web site, for members of my family and forth, with iWeb i realise that things are much eaiser, all i have to do is drag and drop, input my text, or resize windows and so on, i do not need to tap in any code as iWeb is doing that job for me. It's a very great app for amature. After using iWeb for a good while and really enjoy using it, i'm now wondering if there are the same kind of software to build really simple application for mac. Simple application such as memo notes, simple dairy with calendar inside, etc... i know about the Xcode, but that require me to tap in codes and more over Xcode is just too huge for me to finish learning all the featuers it has in no time, so no i don't want to use Xcode because i don't know how the codes for creating cocoa apps for OS X Lion.
    If you know any other programing softwares for mac which really doesn't require much of coding but instead work almost like dreamweaver or iWeb for web site building, please advice me here, it doesn't matter to me if it's free or shareware.
    Thanks in advance for your input and your time.

    Take a look at Automator.

  • Very simple program

    All i wanna do is create an object...but im having compilation errors.
    import java.util.*;
    public class AtypeName{
         public static void main(String args[]){
              ATypeName a = new ATypeName();
    }the errors are
    java:11: cannot resolve symbol
    symbol : class ATypeName
    location: class AtypeName
    ATypeName a = new ATypeName();
    .java:11: cannot resolve symbol
    symbol : class ATypeName
    location: class AtypeName
    ATypeName a = new ATypeName();
    ^
    2 errors
    Process completed.

    The class name is AtypeName, not ATypeName.
    AtypeName a = new AtypeName();http://java.sun.com/developer/onlineTraining/new2java/programming/learn/

  • Very simple question pls help me

    I just want to use oracle sql and pl/sql workshop isqp*plus web site, so which product or software shouuld i download??? pls help me.
    thanks.

    Pl see your other 2 threads on the same topic (posting the same question multiple times does not make the issue go away ;-) )
    Oracle install error 10g 64 bit windows
    which product should i install??
    HTH
    Srini

  • A very simple question, please help.

    How would I output/print out a string in color rather then the standard black?
    If anyone can help me or point me in the right direction would be greatly appreciated.
    For example for extra clarification, if I want to print out a string "Hello World", how can I print it out in different colors such as in blue or red.
    Output to a JApplet ( TextArea)
    Thanks!
    Edited by: ff4930 on Nov 30, 2007 9:18 AM

    You can change the colour of all the text in a JTextArea by setting its foreground property:
    yourComponent.setForeground.setColor(Color.RED);If you just want have multiple colors in one JTextArea, that's not possible. You will have to use a more advanced component, like JEditorPane or JTextPane:
    http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
    In basic cases, if the text doesn't have to be editable by the user, you can use a JLabel and pass it simple html:
    String text = "<html><font color='red'>red text</font> " +
    "<font color='green'>green text</font> " +
    "<font color='blue'>blue text</font></html>";
    yourLabel.setText(text);

  • Photoshop CC constantly bringing up error "Photoshop could not complete request because of a program error" Help!! How do I fix this?

    I have recently been having an error message pop up every now and  then in photoshop CC.  It usually happens after editing every other photo.  It goes away if I close out of photoshop and load it back up. But then it comes back after another couple photo edits. Does anyone know how to troubleshoot this?
    Thanks!

    Nobody can tell you anything without proper system info or other technical details like the actual crash logs. From your description it simply sounds like your graphics hardware is acting up, so update the graphics driver. Likewise, you may simply run out of disk space for the PS scratch file, so check that, too.
    Working with your Operating System’s Tools | Mylenium's Error Code Database
    Mylenium

  • Very simple java project (help please)

    Hello. For a project I have to somehow use MouseListener to make something. My idea was to have a rectangle in which a circle (hockey puck) follows the user's mouse and whenever the user places the circle into a certain area the count goes up by one (like a game of hockey). If someone could give me some idea as to where I should start it would be greatly appreciated.
    My thanks

    This is alwyas [a good place to start|http://java.sun.com/developer/onlineTraining/] when you don't have a clue what's going on, and here if you need specifics on MouseListener. And to get movement, then you'll probably want to look here.
    Once you have some code and specific questions, literally almost everyone on here will be willing to help you further along the way. When you post code, please use code tags.

  • Creating a very simple dice game - help needed

    I have been assigned to create a simple dice game with the result like below :
    Welcome to the Dice game.
    Please answer the following questions with 2-16 characters :
    Whats the name of player 1? a
    wrong format
    Vad heter spelare 1? Duffy
    Vad heter spelare 2? John
    Duffy throws: 6
    John throws: 4
    I have come to the "Duffy throws 6" part and have absolutly no idea how i should continue. I have tried to look up the codes in "API Specification" but found no codes / names with "dice" :)

    I have come to the "Duffy throws 6" part and have
    absolutly no idea how i should continue.How on earth should it continue??? I can't mind read unfortunately.

  • Can't run very simple DOM parsing source on my machine - please help :(

    Hi Guys,
    I am trying to run the following very simple program on my machine to parse a very simple XML file.
    It just returns Document object NULL.
    Same code is working fine on another machine.
    Note: there is no silly mistake. i have valid xml file at valid place.
    Please help.
    import org.apache.xerces.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import java.io.*;
    class XML
         public static void main(String[] args)
              try{
                   String caseFile = "c:\\case-config\\config.xml";
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   factory.setValidating(true);
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   Document doc = builder.parse(caseFile);
                   System.out.println("\n\n----" + doc);
              }catch(Exception e)
                   e.printStackTrace();
    }

    You could also work with JDOM, which I find easier to use than regular DOM:
    import org.xml.sax.InputSource;
    import java.io.FileReader;
    import org.jdom.input.SAXBuilder;
    import org.jdom.Document;
    String caseFile = "c:/case-config/config.xml";
    InputSource inputSource = new InputSource(new FileReader(caseFile));
    SAXBuilder builder= new SAXBuilder();
    Document document = builder.build(inputSource);Just an alternate suggestion.

  • Very Simple C question - reading input parameters/flags... [SOLVED]

    This is an extremely simple question. Please forgive me for being a noob. I am writing an application in C (with GCC) called GAPE and need to be able to pass it parameters through a shell script (/usr/bin/gape) that can determine how it runs. To start with easy stuff, I want the end-user to be able to type "gape -V" to output the version of the program. How do I do that? I understand that I need to put the shell script in /usr/bin...where should I put the actual gcc-compiled gape application? Or do I even need a shell script? Can I just put the GAPE binary in /usr/bin and pass parameters to it directly? If so, how do I do that in C? Any help is greatly appreciated.
    Last edited by tony5429 (2008-03-10 12:00:21)

    include <stdio.h>
    main(int argc, char *argv[])
    int i;
    for(i = 1; i < argc; i++) //argc = the number of arguments
    printf("param nr %d: %s\n", i, argv[i]); // argv[i] contain the arguments, with 0 being the program name (anyone may correct me here)
    [jaqob@p238 c++-egna]$ ./a.out 1 2 3
    param nr 1: 1
    param nr 2: 2
    param nr 3: 3
    [jaqob@p238 c++-egna]$ ./a.out -h -V -zxvf
    param nr 1: -h
    param nr 2: -V
    param nr 3: -zxvf
    A very simple program that prints the parameters
    And yes, you can put the program in /usr/bin/ without a shellscript
    Last edited by JaQoB (2008-03-05 18:09:34)

  • Using Adobe Photoshop CS2 version 9 and have updated it, but when stacking photos, it comes up with PSD, whereas I want Jpeg, and I change the format to Jpeg and the box then comes up with cannot save as there is a program error. Be very grateful for help

    Using Adobe Photoshop CS2 version 9 and have updated it, but when stacking photos, it comes up with PSD, whereas I want Jpeg, and I change the format to Jpeg and the box then comes up with cannot save as there is a program error. Be very grateful for help with this, please.

    jpg does not support Layers.
    Just to make sure, what exactly do you mean by "stacking photos" and what do you want to achieve thereby?

  • Photoshop CC program error when opening or placing files. VERY FRUSTRATING PLEASE HELP.

    I'm an advertising graduate student that relies heavily on Adobe programs for my multiple simultaneous projects throughout the school year, specifically Photoshop, Illustrator, InDesign, Muse, Edge Animate and Premiere Pro.
    I'm using a MacBook Pro running OS X Yosemite.
    I have been experiencing an incredibly frustrating issue with Photoshop and Muse, both CC 2014. I'll speak about Photoshop in this thread since, well, this is a Photoshop forum. This has been happening for almost a year now. I figured Adobe would've fixed this problem by now, especially given the myriad of crash reports I send.
    While working in Photoshop, sometimes when I go to place a file I get an error message that says "Could not complete your request because of a program error." It used to be that this error was fatal and I would have no other choice but to force quit out of Photoshop and restart it. We all know how incredibly time-consuming it is for Photoshop to open (especially 10-15 times in one sitting), and being in grad school, time is not something I have a lot of when I have deadlines and projects due.
    This error is still happening and for the same reasons; however, now I can still continue to work on my file, as long as I don't need to open a document or place an image...which doesn't help very much because I'm doing a lot of mockups and composites and need those functionalities. It happens probably 90% of the time when I try to place or open a document.
    For the record, it's a similar issue that's causing Muse to crash as well. When I try to add an image file, it causes the entire program to crash "unexpectedly," as Muse so eloquently puts it.
    Until recently I had kept CS6 on my hard drive and would dig it out to use in place of CC when PSCC would crash; however, someone told me that having both versions was likely the cause for the crashes. After much hesitation, I finally uninstalled all of CS6 from my hard drive the other day (the right way, not into the trash can, since someone is inevitably going to ask that question) and I'm still having this problem, and now I don't have my CS6 version to fall back on and now I'm in a really bad spot.
    I apologize for all the rambling, but I'm really very, very frustrated with this error, and I had to do something while waiting for Photoshop to restart. Someone please help.

    MacOS 10.10? Yeah, Apple is working on that bug.  They already fixed the crash in the open/save dialogs, but have a few more problems to address with the open/save dialogs.

Maybe you are looking for