Inputing into variables.

I'm a C++ programmer, but my teacher wants me to program a herkle game in Java. I could easily do it in C++, and I know that the two languages are similar, but I dont know alot of the keywords, like in C++, you'd use cout <<. In java, you'd use system.out.println(". What i'm trying to get to is I need to learn how to input into variables. Like let the user assign a value to a variable or string. Thaks for any help

Gui = Graphical User Interface; Command Line = DOS
also, just use this file, save it as PrimitiveInput.java and compile it with the javac tool that comes with the Java Development Kit:
import java.io.*;
* This class provides a collection of basic methods to perform
* primitive type console input.
public class PrimitiveInput
static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
* read the next line from the keyboard as a String
* @return the line as a String
* @throws IOException
public static String readString() throws IOException
return in.readLine() ;
* read the first character on the line
* @return the first character on the line
* @throws IOException
public static char readCharacter() throws IOException
String s = in.readLine();
if (s.length() == 0)
return '\0';
else
return s.charAt(0);
* read the next line as an integer
* @return the line as an integer
* @throws IOException
public static int readInteger() throws IOException
try
String line = in.readLine();
int i = Integer.valueOf(line.trim()).intValue();
return i;
catch (Exception e)
throw new IOException("invalid integer format");
* read the next line as a float
* @return the line as a float
* @throws IOException
public static float readFloat() throws IOException
try
String line = in.readLine();
return Float.valueOf(line.trim()).floatValue();
catch (Exception e)
throw new IOException("invalid float format");
* read the next line as a double
* @return the line as a double
* @throws IOException
public static double readDouble() throws IOException
try
String line = in.readLine();
return Double.valueOf(line.trim()).doubleValue();
catch (Exception e)
throw new IOException("invalid double format");
} // End PrimitiveInput.java

Similar Messages

  • How to create one submit form for both input an variable ports ?

    Hello,
    I would like to create an input from for a query I have.
    The problem is that this query has both input an variable ports and each one creates a different input form. I would like to join it into one form or at least have it under one "Submit" button so the user won't need to fill two forms.
    How can I achieve this?

    Hi Mario,
    Thank you for your quick reply.
    >>Even if you could, only port would be effective.
    Can you please elaborate?
    >> You need to change your query and make your input port-fields variables?
    So, if I understand correctly I should select whether I go for only inputs or only variables?
    Thanks,
    Roy

  • Input hierarchy  variable is not working

    Hi,
    i have created a BI quary which have a manual input hierarchy variable.Now i have created a Universe on it,and then Qaaws.
    In Qaaws this varibale working fine,its gives proper result aCcording to selection of node.Then i have used this in Xcelsius,i have created a connection and then as input value i provided ROOT node key thorugh mapping this to one cell, and mapped the output cell.
    Now if when i preview it,its showing no data,and if remove the input node value(balnck cell) then its showing data.I find out that its not taking the value.
    What could be wrong here?How  to pass hhierarchy  node in xcelsius?
    Thanks,
    Piyush

    Hi,
    I had the exact same problem. Please have a look at this thread:
    xPost: QaaWS, BW, Xcelsius and aggregation
    Here is what you need to do (assuming you are on XI 3.1 SP2)
    1) Refresh you universe with the option Generate technical names. This will give you an additional detail for each dimension in your universe called ...techname. So if you now check e.g. L01, L02 in your hierarchy they will have this attribute.
    2) Create a new web service that includes key and the techname detail
    3) Insert this into your visualization and use it to fill e.g. a combo box (key) and return the key + techname when selected
    4) You can then use the techname to filter your second web service in the input values
    Hth.,
    Jacob Lund

  • IP: Use of input-ready variable in planning function

    Dear all,
    I'm using an input-ready variable for fiscal year (0P_FYEAR) in my input ready query. It's used for restricting my columns.
    I'd like to use the value of this variable in my planning function and I use VARV for that in the FOX.
    However, when implementing the pl.function as a button in the BEx Analyzer I need to fill in the static parameters the VAR_VALUE_1 with a value.
    If I delete this line from the static parameters my plfunction end swith an error.
    I like this value of course to be filled with value of fiscal year entered by the user when starting the query.
    Does anybody know how to solve this?
    Kind regards, Harjan

    Hi Johannes,
    Thanks for all the useful information!
    Another thing on using PF.
    I've got two workbooks with different queries but using <u>same</u> filter.
    Queries differ in keyfigures, but are on same cubes in MultiProvider.
    I can run the workbooks simultaneously: no locks occur.
    I've got two planning functions that make calculations on the keyfigures entered in the workbook.
    However when I inplement the PF's in both workbooks and assign the dataprovider as filter, i do get locks!
    So, the PF also uses the same filter, but doesn't take into account the different keyfigures.
    In the fox-formula i don't have the option to make conditions on keyfigure values (field keyfigname), neither to enter them in the filter.
    Do you have any thoughts on this?
    <u>Second</u> point:
    When i filter on a navigational attribute and execute the pf, i get errors on my pf.
    It states it can't find the value of the characteristic to which the navigational attr belongs. F.i. when i filter on nav attr 'customer group'  (attr of char 'customer') and execute pf, the system gives an error on the value of char 'customer'.
    It states: value of characteristic customer is notincluded in the selection.
    Any thoughts on this one?
    Thanks in advance!
    Kind regards, Harjan

  • BPEL Invoke: Input Header Variable

    Is there a simple way to replicate the Input Header Variable that is part of JDeveloper 10g for BPEL Invoke activity?
    Doing some work with 11g TP3 to work with salesforce.com and need to include a Session ID in the header of the massage sent to invoke a salesforce web service.
    I made the change by manually pasting 'bpelx:inputHeaderVariable="headerRequest"' into the BPEL XML source document for the Invoke activity.
    I'd also be interested in a way to more easily set the EndpointReference of the Partner Link than first importing ws-addressing.xsd schema document into the BPEL Project in order to next create an EndpointReference Element type variable, then copying an XML Fragment to the EndpointReference variable before finally setting the Web Service URL at runtime?
    Thanks,
    Mark

    I started with the example code included with SOA Suite 10g.
    All of the steps from that example, except the Input Header Variable, could be done the same way in both 10g & 11g.
    To make things work, I had to manually paste the code noted in my initial post to BPEL XML source document.
    I'm hoping TP4 or other future release will have the ability to include the header variable in the visual design tool.
    I'm also hoping TP4, which I haven't used yet, or future release of the BPEL desginer in JDev 11g will come up with a simpler way to dynamically set the address of a partner link invoke.

  • Error while running a query-Input for variable 'Posting Period is invalid

    Hi All,
    NOTE: This error is only cropping up when I input 12 in the posting period variable selection. If I put in any other value from 1-11 I am not getting any errors. Any ideas why this might be happening?
    I am getting the following error when I try and run a query - "Input for variable 'Posting Period (Single entry, mandatory)' is invalid" - On further clicking on this error the message displayed is as follows -
    Diagnosis
    Variable Posting Period (Single Value Entry, Mandatory) is used as a lower limit (X) and an upper limit () in an interval selection. This limit has the value #.
    System Response
    Procedure
    Enter a different value for variable Posting Period (Single Value Entry, Mandatory). If the value of the other limit is determined by another variable, you can change its value also.
    Procedure for System Administration

    OK.
    Well, if the variable is not used in any interval selection, then I would say "something happened to it".
    I would make a copy of the query and run it to check if I get the same problem with period 12.
       -> If not, something is wrong in the original query (you can proceed as below, if changes to original are permitted).
    If so, then try removing the variable completely from the query and hardcode restriction to 12.
       -> If problem still persists, I would have to do some thinking.
    If problem is gone, then add the variable again. Check.
       -> If problem is back, then the variable "is sick". Only quick thing to do, is to build an identical variable and use that one.
    If problem also happens with the new variable, then it's time to share this experience with someone else and consider raising an OSS.
    Good luck!
    Jacob
    P.S: what fisc year variant are you using?
    Edited by: Jacob Jansen on Jan 25, 2010 8:36 PM

  • How can I have multiple inputs into the selector terminal of a case structure

    Hi everyone
    I have a question on how to wire multiple inputs in to the selector terminal of a case structure. 
    Currently, I have three switches, each switch determines different case. So if I switch the switch 1 is on, the numeric indicator will show 1. If the switch 2 is on, the numeric indicator will show 2, so on and so forth. However, the selector terminal will not allow me to wire multiply inputs into the case structure, I tried Bundle by Name, Bundle and Array to Cluster, but they did not work. I set the case structure with 3 cases, they are 1, 2 and 3.
    Could someone help me please. I have attach an image and the VI of the work I did so far.
    I have another question, is there a function which can toggle other switches to off when there is a switch has been toggled on.
    Thank you very much
    Tommy
    Attachments:
    Trial - Case Structure.vi ‏7 KB

    Tommy, attached find a cheeseball way of doing this that has given me a LOT of mileage over the years.  IT lends itself nicely to a couple of really good practices that NI recommend, but I have given you the bare-bones to "see under the hood".  
    The recommended practices:
    1. You can make this a nice tight sub-vi where you can put it into a core library of routines that you'll use over the years, even extending the logic to look only for changes, etc.
    2.  If you are thinking about Front Panel design considerations, you'll want to use arrays of controls where possible, as that's a nice neat way of containerizing your switch for both the FP and Block Diagram.
    Have fun.  I have TONS of these types of things, so feel free to PM me if you have any other needs.
    Wes
    Wes Ramm, Cyth UK
    CLD, CPLI
    Attachments:
    Boolean Switch Logic.vi ‏11 KB

  • SAP BI - OLAP variable in DTP unable to read from input ready variable in query

    Hello,
    Here's the problem:
    We have a process chain which is launched in a WAD.
    We would like to filter the DTPs in the PC with the values entered in the variable screen of the WAD
    I created a variable of type customer exit X which reads the input ready variable Y in CMOD.
    Customer exit variable X was placed in the filter of the DTP.
    The input ready variable Y in the query contained in the WAD.
    I am getting an error that customer exit variable X is getting not value.
    Is it possible to read an input ready variable in a customer exit variable placed in a DTP?
    Or am I missing a step here?
    Please help.
    Thanks in advance

    Hi Anjalee,
    Maybe it would be good to share a bit more information on your scenario and the chosen solution design. I am currently missing the point of triggering a Process Chain using Web Application Designer.
    Anyway, I recommend to be careful with using OLAP variables in DTP filters. For sure not all functionality is present, e.g. because the variable pop-up is absent. Your constellation of an input ready variable and a customer-exit variable will only work in the context of a BEx Query and probably not if used in a DTP filter.
    Best regards,
    Sander

  • Workbook does not contain any input-ready variables

    Hello Experts,
    We have one workbook which is not reacting when click on REFRESH or SHOW VARIABLE.
    If clicked on VARIABLE screen it is throwing error "The workbook does not contain any input-ready variables" (screenshot attached)
    Points I have checked are as below
    1. If I create a new workbook by executing the respective query and refresh then it is working.
    2. The file is in xls format and I have checked the USE XLS format under Global setting.
    3. My Excel version is 2010. SAP version is SAPKW70105. BEx 7.X, support package 8.
    4. It is not authorization issue otherwise the issue would have happened for the new workbook I created for testing.
    5. Also I tested with user ID with SAP ALL access.
    is there any way to repair the workbook so that it respond to Variable and refresh options ?
    Thanks,
    Gopi R

    Work book might be corrupted  : As other said need to create / Recover Old work book
    Refer Below  Doc  process For   recovering a  corrupted workbook :
    How to recover a corrupt workbook.

  • Need to validate file Name,split the file name and store the splited values into Variables

    Dear All,
    Below is the my requirement.
    I have a folder, in that folder I have bunch of text files. The file name is below format
    ACA_122_pay_20140430_001
    Initially the file name start with ACA code,groupid,group name and date time stamp. This is the standard structure of file name.
    I want to check each and every file in the folder with this structure. The structure should be standard for all the files. If the structure same for all files I need to get codes form file name. For example
    If you see the below file name, I need to get ACA and put into variable,I need to get 122 and put into variable. For group name and date time needs to put in variable.
    If the file format is not valid state then I need to log exception.
    Let me know if I am not clear.
    Kindly provide the C# code for achieving the above requirement.
    As I am new to .net programming. kindly help me.
    Thanks in Advance,
    Regards,
    Madhava Ganji
    Madhava Ganji

    Hi MadhavaGanji,
    I have post how to validate the file name, header row against definition table which stored the file name and column definition. 
    Take a look and see if this is helpful.
    http://sqlage.blogspot.com/2013/11/ssis-validate-file-header-against.html
    http://sqlage.blogspot.com/

  • SELECT INTO ( variable ) STATEMENTS NOT WORKING FOR SYBASE TABLE AS VIEW

    Dear Experts,
    We have connected our 9i db with Sybase db using Hs connectivity.
    and then we have create the view in oracle db for SYBASE_TABLE as SYBASE_TABLE_VIEW.
    ALL THE INSERT, UPDATE AND DELETE COMMANDS ARE WORKING BUT THE
    select Into (variable) is not working.
    Please help to resolve the select into statment which is in BOLD in the below routine
    PLEASE NOTE! FORM WAS COMPILED SUCCESSFULLY AND FORM IS RUNNING BUT SELECT INTO COMMAND IS NOT WORKING.
    Thanks & Regards
    Eidy
    PROCEDURE SRBL_INSERT IS
    CURSOR SRBL IS
         SELECT impno,impcod,impnam
         from oracle_table1 a, oracle_table2 b
         WHERE a.impcod=b.empcod
         v_srpcod varchar2(5);
    BEGIN     
    FOR rec in SRBL loop     
         begin
    select "im_code" into v_impcod                    
         from SYBASE_TABLE_VIEW
         where "im_code"=rec.impcod;
    exception when no_data_found then
         v_srpcod:=null;
    end;
    END LOOP;
    END;
    Edited by: Eidy on Aug 16, 2010 11:28 AM

    hellow
    try this.
    select "im_code" into v_impcod
    from SYBASE_TABLE_VIEW
    where "im_code"=rec.impcod;
    v_srpcod := v_impcod ;
    ........

  • Animations in Flash ads blocking text input into rich-text editor (IE)

    We've been able to reproduce that Flash ads, that are currently animating, block text input into rich-text areas.  Has anyone heard of this?

    I should add, they do not block all text input, just every 10th (or so) character.

  • Assign string into variable

    Hi All!
    I''ve created global and lоcal variable with type - string
    How can I assign the value into variable in BR?
    I tried [Var_1] = "qwe"; or [Var_1] = @CONCATENATE (String_1, String_2) it doesn't work
    Regards
    Sasha

    You should be able to take global/local variables from HBR into the code and use concatenate within the HBR.
    Something like
    @CONCATENATE([varName1], [varName2]) shouldn't be a problem, so long as the values are good.
    Regards,
    Cameron Lackpour

  • Read a file content into Variable

    Hi There,
    I've a file in Unix and the content of it need to be assigned to an ODI variable. How can I do it?
    Regards.
    -Bhavani

    Step 1. ODI procedure .
    Command on Target - Java bean shell.
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    BufferedReader br = new BufferedReader(new FileReader("C:\\test.txt" ));
    String strLine = br.readLine();Step 2
    Create variable and add
    SELECT '<@=strLine@>' from dual This particular code will read only first line and pass into variable.

  • ForEach Loop - Parsing XML subgroup into Variables

    Hi all,I am designing a new ETL process using SSAS.
    We have a controller package which receives an XML string at run time into a variable called BatchRequest :-
    <Batch>
    <Request>
    <Name>Filemon</Name>
    <Params>
    <filepaths>
    <Sourcepath>d:\temp</Sourcepath>
    <Destpath>D:\temp2</Destpath>
    <Archivename>\Archive</Archivename>
    </filepaths>
    </Params>
    </Request>
    </Batch>
    The Batch can contain a number of Requests and a ForEach Loop is used to parse the text for the Name node and the text for the Params Node into variables RequestName and RequestParams respectively.
    however, what I want to be able to do is to take the text for <name> into Requestname but take the entire XML sub string for <Params> into RequestParams.
    At the moment I get the text only (e.g. d:\tempd:\temp2\Archive).
    The Requestname is used by an XML task within the ForEach loop to retrieve full package path details from an external config file, and hence it only needs to be a keyword.
    I played with the idea of including <Params> as a subnode for <Name>, only populating RequestName in the loop parser and then having an XML task which would parse the related parameter string, but i don't know how to tell the XML task that I
    want the parameter string where the <Name> is Filemon (in this example).
    Can anyone give me some suggestions or pointers?
    Thanks
    Iain
    Iain

    Hi idcowden,
    Glad to hear that you have resolved the issue on your own. Thank you for sharing the solution.
    Regards,
    Mike Yin
    TechNet Community Support

Maybe you are looking for

  • Why do I keep getting the rainbow spinning wheel in Garageband 11

    I have the latest MBP (see specs below) and I was recording today with Garageband like I always do.  I was using my MOTU 828 MK1 8 channle audio interface with the lates compatible Lion update from Sept 2011.  I have never had any problems untill las

  • Java.io.filepermission error while executing a batch file from java prog

    Hi, i want run a java program which executes a batch file, both are in a jar file. while am trying this using webstart it shows error:access denied java.io.filepermission <<ALL FILES>>execute. why this happens how to rectify this. By Vinod

  • Converting a delimited string to a string array

    I have a string: (no quotes) "Aout,B,Cin,D,Etest". I want to convert this into a 1D array of  Aout B Cin D Etest I could not find a VI that does that. Best way to do this ? Solved! Go to Solution.

  • Icloud keychain activation/verification issue-

      GREETINGS & SALUTATIONS!   --> _so, - - - - first things first, i suppose: Machine information [model/year/os/etc.] iMac 21.5", mid 2011 Processor: 2.5GHz intel core i5 Memory: 4GB 1333 MHz DDR3 Graphics: AMD Radeon HD 6750M 512 MB Serial No: C02GW

  • Communication Channel Logs

    Hi All, Is there a audit log available for sender communication channel . 1)The sender communication channel tried to pick up some files 2 days back.I wanted to check the log of Sender Communication Channel for the problem today for why the files did