Adding to a string name

I need to getthe int count added to the name of an int rand.
is this possible? rand + count = input.getUserInput("Answer");?
public class jepmain {
      * @param args
     public static void main(String[] args) {
          int i = 0;
          String quitornot = "";
          getInput input = new getInput();
          int count = 0;
          jebquestions trivia = new jebquestions();
          System.out.println("-----------------------------------------");
          System.out.println("Trivia game!");
          System.out.println("by ");
          System.out.println("-----------------------------------------");
          System.out.println("Rules: Put caps where caps are needed, no commas, no dashes, just letters and numbers");
          System.out.println("The game keeps going until you get one wrong");
          while (i == 0) {
               int x = 0;
               while (x == 0) {
               count++;
               int rand = (int) (Math.random() * trivia.questions.length);
               System.out.println(trivia.questions[rand]);
               String answ = input.getUserInput("Answer");
               if (answ.equals(trivia.answers[rand])) {
                    System.out.println("Correct");
                    x=0;
               else {
                    System.out.println("wrong");
                    x--;
               //alows the user to play again
               quitornot = input.getUserInput("Do you want to play again[yes, no]");
               if (quitornot.equals("yes")) {
                    i = 0;
               if (quitornot.equals("no")) {
                    i++;
                    System.out.println("Thank you for playing the trivia game");
                    System.out.println("by ");
                    System.out.println("Goodbye");
}thanks

sys5 wrote:
I need to getthe int count added to the name of an int rand.
is this possible? rand + count = input.getUserInput("Answer");?No you don't, trust me. What you need is an array.

Similar Messages

  • Adding to a string array

    hi,
    seem to be having some trouble adding to a string array of names
    im trying to take a name from a text field and add it to the array
    help would be much appreciated
    this is the string array
    String[] AuthorString =     {"John Grisham","Agatha Christie","Nick Coleman","Scott Sinclair"};which is loaded into
    public void fillArrayList(){
         for(int a=0; a<AuthorString.length; a++) {
         AuthorList.add((String)AuthorString[a]);
                         }i then try and add to this using
    public void AddMember(){
         String temp = (String)AuthorField.getSelectedItem();
         for(int a=0; a>AuthorList.size(); a++) {
         String temp = (String)AuhtorList.get(a);
              AuthorString .addItem(temp);
          }can anyone see any problem with this, or am i doing it the completely wrong way

    Also, your "for" loop's test condition is backwards. It should use "less than":
    a < AuthorList.size()

  • Where I have to give the host string name of oracle server in WSAD?

    hi,
    I setup the oracle in my WSAD.But,Its giving below error.
    [3/16/06 13:25:41:332 SGT] 3e75fec4 WsServer A WSVR0001I: Server server1 open for e-business
    [3/16/06 13:25:42:535 SGT] 68bb7ec6 WebGroup I SRVE0180I: [Sample] [Sample] [Servlet.LOG]: ResultData: init
    [3/16/06 13:25:42:551 SGT] 68bb7ec6 SystemOut O the connection started
    [3/16/06 13:25:42:551 SGT] 68bb7ec6 SystemOut O no connection
    [3/16/06 13:25:43:535 SGT] 68bb7ec6 ConnectionFac I J2CA0122I: Resource reference jdbc/MyDataSource could not be located, so default values of the following are used: [Resource-ref settings]
         res-auth: 1 (APPLICATION)
         res-isolation-level: 0 (TRANSACTION_NONE)
         res-sharing-scope: true (SHAREABLE)
         res-resolution-control: 999 (undefined)
    [Other attributes]
    isCMP1_x: false (not CMP1.x)
    isJMS: false (not JMS)
    [3/16/06 13:25:44:285 SGT] 68bb7ec6 FreePool E J2CA0046E: Method createManagedConnctionWithMCWrapper caught an exception during creation of the ManagedConnection for resource jdbc/MyDataSource, throwing ResourceAllocationException. Original exception: com.ibm.ws.exception.WsException: DSRA8100E: Unable to get a PooledConnection from the DataSource.
         at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:244)
         at com.ibm.ws.rsadapter.exceptions.Dat
    [3/16/06 13:25:44:426 SGT] 68bb7ec6 SystemErr R      at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPhysicalConnection(OracleConnectionPoolDataSource.java:109)
    [3/16/06 13:25:44:426 SGT] 68bb7ec6 SystemErr R      at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPooledConnection(OracleConnectionPoolDataSource.java:77)
    [3/16/06 13:25:44:426 SGT] 68bb7ec6 SystemErr R [3/16/06 13:25:44:426 SGT] 68bb7ec6 SystemOut O Error on find the database() : java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    The Connection descriptor used by the client was:
    SGGSGPTP31DT197.code1.emi.philips.com:1521:CESS
         at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPooledConnection(OracleConnectionPoolDataSource.java:59)
    [3/16/06 13:25:44:426 SGT] 68bb7ec6 SystemErr R      at com.ibm.ws.rsadapter.DSConfigurationHelper$1.run(DSConfigurationHelper.java:759)
    [3/16/
    But,I given correct URL.The URL I given is
    jdbc:oracle:thin:@sggsgptp31dt197.code1.emi.philips.com:1521:CESS
    sggsgptp31dt197.code1.emi.philips.com -- this is my host machine.
    I think the problem with host string.
    actually when we are trying to enter into the oracle sql,it asking the username,password and host string.I mentioned the username and password in variables tab.I don't know where I have to mention the host string name.
    Please any one help on this.
    Thank you,
    D.Nagireddy.

    I would say that, since the OP has so little info, there are no policies in use.  It there were then this question would never be asked the way it is being asked.
    I had a client call with a letter from their insurance company; an accountant with malpractice insurance.  THey asked the same question inmuch the same way.  "What computer can you users access?"  The question should be more like
    "Do you have a policy that restricts access to computers and do you audit for compliance?"
    I have had other clients whose insurance asked the question in that way.  It produces a better view of what should be happening and how to show compliance.
    I recommend that companies being asked these questions by their legal departments or insurance companies should contract with a god computer security consultant to assist with answering these very tricky questions.  Of course if it is just you boss's
    curiosity  then you may need to discuss his requirements with him in more depth.
    ¯\_(ツ)_/¯

  • Just updated my iphone. Now I can se I have two? iCloud accounts? One of them appears on my phone, and I have forgotten the password. When I try to add the other account, I get the message that this account is already added, but with the name of the first

    Just updated my iphone. Now I can se I have two! iCloud accounts? One of them appears on my phone, and I have forgotten the password. When I try to add the other account, I get the message that this account is already added, but with the name of the first account where there is no available password. I have tried several times to reset the password, bun I don't get the information I need - I have no access to email. What can I do?

    Hi, thanks for the suggestion. I have tried as you suggested, and when opening the "purchased" apps some have the icloud logo next to them, but I only have "OPEN" against "Find My iPhone". When opening it up, it goes through the same routine; needs to be updated before proceeding, and wouldn't update because I don't have IOS8.
    Anything else I could try, or am I doomed!
    All of your help is much appreciated, thanks

  • SSMS 2012:XQuery-doing "Retriving Job Candidates with the query Method" in AdventuresWorks 2012. Unclosed quotation mark after string '//*:Name.First?

    Hi all,
    From Page 354 of the the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles (published by apress), I copied the following code (Listing 12-9 Retrieving Job Candidates with the query Method):
    --Coles12_9.sql // saved in C:/Documemnts/SQL Server Management Studio
    -- Coles Listing 12-9 Retrieving Job Candidates with the query Method
    -- Doing XQuery and the xml Data Type in AdvantureWorks
    -- 17 March 2015 1105 AM
    USE AdventureWorks;
    GO
    SELECT Resume.query
    N'//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    I executed this set of Listing 12-9 code in my SQL Server 2012 Management Studio and I got the following error messages:
    Msg 105, Level 15, State 1, Line 4
    Unclosed quotation mark after the character string '//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    Msg 102, Level 15, State 1, Line 4
    Incorrect syntax near '//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    I am not able to figure out why I got the error messages.  Please kindly help and advise me how to correct this set of sql codes.
    Thanks in advance,
    Scott Chang

    Hi Scott,
    I don't have that book at hand, but your problem is the "Unclosed quotationmark after the character string",as the error message shows. You have to enclose the 'XQUERY' string quotation in the
    query().
    SELECT jobcandidateid, Resume.query
    N'//*:resume,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level' --enclose the quotation here
    FROM HumanResources.JobCandidate;
    For XQUERY learning, here is a good
    link.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • How do I prompt a user to enter in a string name and set it so it can be used as an input for a DLL

    I was having problems entering in a string name and setting it. Any suggestions.

    Entering the string is easy. Just use a string control.
    To setup the Call Library Function, right click on it and select Configure. Type in the path to the DLL (or use the Browse function) and then use the Function Name dropdown box to select the function within the DLL. From here, you have to setup the parameters. The return type parameter should already be selected in the Parameter drop down box, so click on the Type drop down box and select the type of parameter that the selected function will return. From there, click on the Add Parameter After button to add an input parameter and then select the type of parameter. Continue doing this for all of the input parameters to the DLL. For strings you'll see a new drop down box appear for String Format. Choose the
    format that the DLL expects.
    You need to know what the DLL is looking for. Have fun with it.
    Rob

  • 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.

  • My iMac has extra numbers added to its share name. e.g Ali's iMac 49886

    I am using Mountain lion, and my computer name keeps changing.
    It keeps saying that it is because the name is already in use on the network, but that is not the case.
    I use an airport extreme base station.
    I am only sing the Ethernet port to connect to the network and wifi turned off.
    How do I stop these numbers from adding to the computer name.
    Ali

    Here is just a sugestion, maybe the airport Extreme thinks that your computer is actually connected twice and hasnt let go of the lease of the IP address. On the old version of Airport Utility you could view attached devices the new one doesnt let you do this but here is a link to the old version.
    http://forums.macrumors.com/showthread.php?t=1343156
    Linc Davis is right, the user accounts have nothing to do with your machine being names twice. I personally think that your name is just stuck somewhere on the network and the boxes all need flushing.
    To do this just simply go round and switch everything off and switch it all back on again and the leases should be renewed.
    This sometimes happens when you move from AP to AP.
    Thank you
    JC

  • Call a function by String name

    In JavaFX, how can one call a function based on it's String name?
    For example, if I had a sequence like ["one","two","three"] how could I call functions one(), two(), and three() by referencing the sequence?
    In other words, what is a better way to do:
    if (sequence[x] == "one")
        one();
    if (sequence[x] == "two")
        two();
    if (sequence[x] == "three")
        three();Thanks in advance.

    Here is a plain old JavaFX class (a pofxo?) with three methods one, two and three.
    package reflectionexample;
    public class FunctionInvocationExample {
        public function one() {
            println("One");
        public function two(message : String) {
            println("Two - {message}");
        public function three() {
            println("Three");
    }So this class has no knowledge of anything to do with reflection, it will be what we will invoke with the code below...
    (place this in some other class file - or a function that gets invoked somehow)
    package reflectionexample;
    import java.lang.Class;
    import javafx.reflect.FXLocal;
    import javafx.reflect.FXType;
    import javafx.reflect.FXValue;
    // create the example object
    var example = FunctionInvocationExample{}
    var exampleObjectValue = FXLocal.getContext().mirrorOf(example);
    var exampleClassType = exampleObjectValue.getClassType();
    var argumentTypesForOne : FXType[];
    var functionOne = exampleClassType.getFunction("one", argumentTypesForOne);
    var argumentValuesForOne : FXValue[];
    // Invoke function "one"
    functionOne.invoke(exampleObjectValue, argumentValuesForOne);
    // To invoke function "two" we need more stuff around the argument types and values
    var stringClass = Class.forName("java.lang.String");
    var stringType = FXLocal.getContext().makeTypeRef(stringClass);
    var argumentTypesForTwo = {stringType};
    var functionTwo = exampleClassType.getFunction("two", argumentTypesForTwo);
    var message = "Hello World";
    var messageValue = FXLocal.getContext().mirrorOf(message, stringType);
    var argumentValuesForTwo = {messageValue};
    // Invoke function "two"
    functionTwo.invoke(exampleObjectValue, argumentValuesForTwo);Which when you run it will produce the following...
    standard-run:
    One
    Two - Hello World

  • Access java variable by string name

    Is there a way in java to set a variable by a string name like the $$ option in php?
    What I'm trying to do is set a global String variable from within a loop of key-value pairs. I want to be able to set each variable dynamically without knowing the variable name.
    Instead of doing this:
    this.myVar = newValue;
    I want to do something like:
    this.{"variableName"} = newValue;
    where the string inside the {""} is unknown and comes from data within the loop and one iteration may be "myVar".

    jhowley wrote:
    Well, I kind of thought that wasn't possible and a Map was my backup plan anyway. Thanks for the info.its totally possible with Reflection (but you should use a Map).
    read: [getField(String)|http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getField(java.lang.String)]
    import java.lang.reflect.*;
    public class ReflectionDemo{
    public static void main(String[] args){
         new ReflectionDemo().start();
    public void start(){
         try{
         Class c = this.getClass();
         Field f = c.getDeclaredField("myField");
         int i = f.getInt(this);
         System.out.println(i);
         } catch(Exception e){
         e.printStackTrace();
         int myField = 11;
    }

  • Execute method by the string name

    Well,
    I want execute a method , just knowing the string name of her and your class too:
    public class A
    public static void Kick()
    public class B
    final String methodToBeExecuted="Kick";
    Or on the same class too.
    This is possible?
    (In C I could use functions pointers on an array)
    A solution can use @Anotation ou "Reflection"
    Thanks

    i've never seen anything like that, my advice is to
    look closer at your design because your problem is
    very easy to circumventOk but this is not a desing problem.
    It's just a performatic problem.
    Im coding an emulator and need to handle opcode.
    swicth (opcode)
    case 0x1:
      method1();
    case 0xA:
      methodA();This code (one processor that have 256 instructions) can produce a slow program and change it to a thing like this:
    final String instruction = "method" + opcode;Is very very very fast... and build an emulator we nedd to forget a little about the patterns and good pratices and make performatic things.
    understood?

  • Preventing select-string from adding additional undesired strings in the output file

    Hi friends
    in PS 4.0 i am trying to write a function which
    step1: export the list of all eventlogs ----> wevtutil el > "$home\documents\\loglist1.txt"
    step2: deleted the following two lines from loglist1.txt
    DebugChannel
    Microsoft-RMS-MSIPC
    ( the reeson of deleting these two lines is wevtutil cl command, can't clear these two evenlogs among approximately 1000 logs)
    in fact via select-string with -pattern -notmatch parameters, we select anything except these two line
    step3:  pastes the select-string contents into the same file ("$home\documents\loglist1.txt") or into new text file (for example
    "$home\documents\loglist2.txt")
    here is my code:
    function MycleareventsAll {
    cls
    Wevtutil el > "$home\documents\loglist1.txt"
    $mycontents = select-string "$home\documents\loglist1.txt" -pattern DebugChannel, Microsoft-RMS-MSIPC -NotMatch
    cd "$home\documents\"
    $mycontents | out-file loglist2.txt"
    # also i tried ---> $mycontents | set-content "loglist2.txt"# also i tried ---> $mycontents | set-content "loglist1.txt"
    but the problem is, in addition of deletion, unfortunatelly additional strings (filepath, filename, line number) are added into the final text file so wevtutil will fail clearing logs listed in text file.
    here is contents of the final text file
    C:\Users\Administrator\documents\loglist.txt:1:Analytic
    C:\Users\Administrator\documents\loglist.txt:2:Application
    C:\Users\Administrator\documents\loglist.txt:4:DirectShowFilterGraph
    but i need the contents be the same as original file without that two specific line:
    Analytic
    Application
    DirectShowFilterGraph
    i searched but i didn't find a way to prevent select-string cmdlet from adding these edditional strings
    (filepath, filename, line number) into output file while keeping the original contents.
    note: -quiet parameter is not what i want. it removes all contents & simply inserts a true or false.
    any help? 

    don't forget that Guys here know the basics of security such as clearing event logs & ...
    how odd if you don't know this.
    clearing all events is useful in test environment for example when i ma teaching my students & need to see all newly created events & work on them
    Then you are teching your students how not to use an event log.  We use filters and queries to access event logs.  We also use event log CmdLets in PowerShell.  WEVTUTIL is ok but it does not marry wellwith PowerShell as you have seen.
    I have found very few people who are not certified in WIndows administration that know much about eventlogs when it should be a ver important part of administration.  PowerShell has mmade EL management much easier but few take the time to learn how
    to use the EL support in PowerShell.
    I see no point inclearing event logs.  It accomplishes nothing.
    ¯\_(ツ)_/¯
    oh your are introducing me filters & queries in event viewer !! please stop Laughing me this way.
    your problem is you judge about people's knowledge & you persist on your absurd judgments.
    look at your sentence:
    "Then you are teaching your students how not to use an event log" 
    where from you tell this? have you been present in my classes to see what i teach to my students?
    have you seen that i told to my students not to use event viewer?
    my goal of clearing events is related to myself. it's non of your businesses.
    people are not interested to here concurrent irrelevant advises from you like a grandmother. they are searching for a solution. their intent of doing tasks is not up to you.

  • String name = new String {...} what is this?

    Hi,
    Java beginner, moving from C++:
    protected String[] name = new String[] {
              Integer.toString(1),
    Integer.toString(2)
         };what does a bracket mean after new String[] ?
    Thanks,

    Thanks, I didn't know what to search for in
    google...
    Is it generalizable to any object?Why don't you try it with various objects and primitives? Then you'll find out for yourself.
    You can also read the JLS
    http://java.sun.com/docs/books/jls/second_edition/html/j.title.doc.html
    or
    http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html
    Or any of a number of books or tutorials. This is basic stuff. It should be covered.
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.

  • How can i use a string name as an onject name.please help!

    hi it seems like an easy one but i can not find it anywhere.how can i use the name of a string as a name of an object such as the code(my problem is the code)...
    public void oda(String name1){ 
    String name2=name1+"s";
    String name3=name1+"ss";
    TextArea name1=new TextArea();
    TextArea name2=new TextArea();
    TextArea name3=new TextArea();
    i think my problem is clear but to be sure..
    how can i give a name to an object in my textarea which is already using as a string.
    thank u .

    it get very compilcated to change the name of the object you created. identity is something you don't want to mess with..you can do it by usin reflection, but it will slow down your application and (again) is quite complicated...
    a simple solution (and more object-oriennted) is to create a Wrapper, Decorator, or Extends the class.
    example
    public class MyTextBox{
        private String name = null;
        private boolean value = false;
        private JTextArea txtArea = null;
        public MyTextBox(String name, boolean value){
            txtArea = new JTextArea();
            this.value = value;
            this.isOn = isOn;
        public String getComponentName(){  return name; }
        pubic boolean getComponentValue(){ return value; }
        public JTextArea getTextArea(){ return area; }
    }

  • How to call methods from string names?

    On my java project i have a front controller. All the requests will first go to controller and i will make parameter validation on the controller level. If validation is completely ok, page will be dispatched to real servlet with validated parameters.
    If the request pattern is "photos" for example i will call static function and send referance of request object Validation.Photos(request); or if the pattern is "albums" function will be Validation.Albums(request).
    everything is ready on my codes except how to call a Validation function with a string name. Need a clear and a fast way because on every request i will do this.
    Thank you

    ahh life is problem;) another one i couldnt understand.
    import javax.servlet.http.HttpServletRequest;
    interface Validasyon {
            boolean invoke(HttpServletRequest request,String param);
         class IntIsNumeric implements Validasyon {
           public boolean invoke(HttpServletRequest request,String param) {
                param=request.getParameter(param);
                System.out.println("param="+param);
                try
                     Integer.parseInt(param);
                catch(NumberFormatException e)
                     return false;
                catch(NullPointerException e)
                     return false;
                int gelen1=Integer.parseInt(param);
                if(gelen1<1 || gelen1>Integer.MAX_VALUE)
                     return false;
                return true;
         }i am sending parameter to IntIsNumeric classes's invoke method like below
    Validasyon c=new IntIsNumeric();
    boolean a=c.invoke(request,"photo_id");but IntIsNumeric method does not recognize my input parameters "request" and "param" always return null. Why?

Maybe you are looking for

  • Airport Extreme migration to Time Capsule

    I just got my new TC and want to change my current wireless network and Internet access from AP Xtreme to TC. Any important tips or advice I should have before beginning? Do I set up a new Network or just migrate? I currently use Time Machine to back

  • My iMac freezes when saving a document in Word 2004

    Any help would be appreciated. When I try to save a document while in Word 2004 the application freezes and I have to force quit. Thankfully I can print the file as a PDF before trying the save as route but this is still a problem. What's the issue?

  • My kids deleted all my contacts except the 3 most recent.  Anyway to get them back??

    Somehow my kids managed to delete all of my contacts except the 3 most recent ones.  I am pretty sure they didn't go into each one and deleted them since there were more than 100.  And I have no idea how only the 3 most recently added ones were kept

  • Using Bex query through Query Browser - add result set to Cell range?

    Hi all, I have up to now used Xcelsius on NW with BICS connection towards BEx queries. When I use this connection via Data Manager in Xcelsius, I'm able to use the Cross-table functionality to insert my entire dataset into a cell Range. But now I hav

  • Send SSH Command using java

    Ok. I hate this, but this is they way they have implemented it. I do not have access to the server code that this applicatio sits on, so I am only able to send specif commands with java through there interface. One of the commands for example is: pas