Need to run program multiple times

I need to be able to run my compiled java file five times all in the same cmd while only using one .java file... I got it to fully work when i only do it once, but how do i make it repeat everything five times?

while (x=5)
x=x+1
allmycode
}You are right: it's not a good idea to throw "allmycode" into a loop.
so like in a while loop how it kind of "forgets" -or however you phrase it- all
the ints/strings and just starts over with the same ones.This is a good description of what a method is (from a non OO point of view).
It "forgets" its local variables.
I agree with flounder, you should probably make a class for your data and a
collection to store them in. But if this not where you are at the moment, you
can still follow your intuition and make a method that processes the
data line by line - effectively forgetting the work it did on the previous line.
Such a method can be called weithin a simple for-loop.
You example would look like this:import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Adder {
    private static BufferedReader in = new BufferedReader(
            new InputStreamReader(System.in));
    private static String[] inputArr;
    public static void main(String[] args) {
        inputArr = new String[5];
            // First read the iput
        for(int i = 0; i < 5; ++i) {
            getInput(i);
            // Then process it
        for(int i = 0; i < 5; ++i) {
            processInput(i);
    private static void getInput(int line) {
        try {
            inputArr[line] = in.readLine();
        } catch(IOException ioe) {
            ioe.printStackTrace();
            System.exit(1);
    private static void processInput(int line) {
        String[] arr = inputArr[line].split(",");
        int first = Integer.parseInt(arr[0]);
        int second = Integer.parseInt(arr[1]);
        String unit = arr[2].equals("I") ? "Inches" : "CM";
        System.out.printf("%d %s%n", first + second, unit);
}

Similar Messages

  • Is it possible to automate the running of a java program multiple times?

    For example, i have a java program which constantly writes the word "hello world" to a text file and ends the program.
    Instead of compiling & running this multiple times is there a way to automate it and it will run it many times as you want?

    Theresonly1 wrote:
    For example, i have a java program which constantly writes the word "hello world" to a text file and ends the program.
    Instead of compiling & running this multiple times is there a way to automate it and it will run it many times as you want?What do you mean by "constantly" and "many times as you want"? Do you mean literally constantly -- as soon as it runs, it runs immediately again?
    Or do you mean something like running it once every half hour indefinitely?
    What i was looking for is something along the lines of a script file or Ant. Like an automation tool. How is this not answering your own question? You can use a script, or Ant.

  • Executing a program multiple times with different variants

    Hi All,
    I want to create a tool which executes a program multiple times taking different variants (which I would be
    maintaining in an excel sheets) and for each time the program gets executed, its output would be
    written to a particular file.
    I understand that this requirement is quite vague but I am trying to figure out if a tool/program could
    be written in abap which does this or do I need to think of a different platform such as C#.Net
    Thanks,
    Faiz

    Hi Rahman,
    This class 'cl_salv_bs_runtime_info' will get the output of internal table.
       DO n times.
          cl_salv_bs_runtime_info=>set
          SUBMIT ZARCHER_0099 WITH VARIANT..(variant name can from your excel sheets?)
          cl_salv_bs_runtime_info=>GET_DATA
          call 'GUI_DOWNLOAD'  or OPEN DATASET...(down output to file)
       ENDDO.
    Hope can help you.
    regards,
    Archer

  • Can you run programs from time capsule? IE can I run microsoft office from it?

    can you run programs from time capsule? IE can I run microsoft office from it?

    Yes, probably can.. but it won't be fast. You are better storing programs locally and data remotely.

  • App needs to run on multiple DBs; can parsing schema/ ref owner be dynamic?

    I have an app that needs to run on multiple databases. Is there a way to create something like an app-level item -- something that only needs to be set once -- that can be referenced to specify the parsing schema, and all of the instances of "reference table owner" used to specify the source for DML? Or (I've not tried this yet) can I just NOT set the value of reference table owner? In my case, the reference table owner for all tables is the same as the parsing schema.
    Thanks,
    Carol

    hi Varad -- I should have been more specific. The application does not need to access multiple databases; rather, it will be installed on multiple databases, operating only on the DB on which it's installed. (Same functionality on each DB, same DB schemas in each, different data in each.)
    So, I'm wondering if there is a way to have the parsing schema somehow be set automatically based on information in the database, or if I'll have to create a slightly different version of the app, w/ different parsing schemas, for each database.
    It was recommended to me (perhaps by you, I can't recall) that the parsing schema be the same as the owner of the tables that the app accesses; the table owner is different in each of these databases, so that is the source of this problem (if indeed it is a problem).
    Thoughts?
    Thanks,
    Carol

  • Does the WD SmartWare needs to run all the time?

    Hi. I use WD SmartWare (not Pro, just the free version) to do my backups to WD My Cloud. I also use WD Quick View, which is running at all times. WD SmartWare is set up to continuous back up (i.e. monitoring my drives and copying files over when new files are added etc.).  Does it have to be running all the time for that or maybe WD Quick View controls the backups somehow? If SmartWare needs to run at all times, is there any way of minimizing it to system tray rather than to the taskbar? It's really annoying that the icon just sits there... I like my taskbar to be tidy! Thanks

    Smartware will run continuously in the background as a service, but no the app GUI itself doesn't need to be open all the time. Once installed it will set itself up to do that, so you only need to open the actual app GUI if you want to start/edit./stop the configuration for the backup itself. Your taskbar can be nice and tidy

  • NEED Help Running Out Of Time+++Q:Opening a PSD file in Illustrator Question???

    Hello everyone!!! Hope everyone is staying dry and warm!!!
    I have some artwork im doing for screen printing and a friend has been sending me some artwork to work on. The problem we are having is some of the artwork will open in Illustrator or CorelX4 and stay editable but then he will send me some that when I open in Illustrator it gives me this message and then will not be editable:
                           """This document has greater than 8-bit depth it will be imported as an 8-bit flat composite""""
    Can anyone tell us why this is happening??? I have researched this with no answers so far??? He is using PSD2 and Im usin PSD4 and Illustrator4
    Please help!!!!! Running out of time for this artwork to be completed.
    Thanks
    Bobby

    Photoshop is capable of saving files that are 16 or 32 bit depth. This has to do with the amount of colors that are accessable. The message you are seeing is telling you that it will convert the file back to 8 bit color space for you. This bit depth is talking about per channel, not over all. So a cmyk file would have 8 bits for cyan, 8 for megenta, 8 for yellow and 8 for black. Having a higher amount of bits per channel, photoshop is then capable of doing things like smoother gradients, retreiving data from raw images to produce an image that shows more highlights and shadows without the clipping and so forth.
    Most basic monitors are only 8 bit, same goes for most printers. So unless you need to access the extra color depth, you should be fine in 8 bit. If you don't want to see this message, just tell your friend to send the images at 8 bit.

  • ALSA audio problem (need to run alsaconf EVERY time!)

    Hi there I've been messing around with Arch for a lil while now and it works great and all for me but I'm dealing with one problem that kind of ticks me off - I have to run alsaconf every time when I boot up my machine. I tried it as root, user, with sudo.. nothing.. it just resets everytime to such low levels that I have to krank my amp all the way up even with all aumix levels maxed out.. what's going on here? Does anyone have similar issues? How can I fix this?

    > I tried it as root, user, with sudo.. nothing.
    Have you tried reading the wiki?
    http://wiki.archlinux.org/index.php/Beginners'_Guide#Step_1:_Configure_sound_with_alsamixer

  • Finder Open With lists programs multiple times

    When I right click on a file in Finder and select Open With, multple versions of the same programs are listed. I've got 5 versions of Evernote, 4 of Pixelmator, 3 of PDFpen and 2 of Skitch. What's causing this? When I look in my Applicaitons folder, there's only the most current version.

    It may be that Launch Services database needs to be rebuilt.
    Copy and paste this command in the Terminal:
    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -seed

  • Flash plugin runs up multiple times

    When opening a page wit flash on it Firefox slows down, has some redrawing glitches. Task manager shos several flash plugins running(5-20)
    Upgraded from 11.7 to 11.8 with no difference.
    Any thoughts?
    Simon

    For the graphical glitches:
    Try disabling Firefox's use of hardware graphics acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches, particularly when drivers get updated.
    You usually need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    orange Firefox button (or Tools menu) > Options > Advanced
    On the "General" mini-tab, uncheck the box for "Use hardware acceleration when available"
    If you restart Firefox, is the issue resolved (or at least improved)?
    Flash has its own acceleration setting as described in this support article from Adobe: http://helpx.adobe.com/flash-player/kb/video-playback-issues.html#main_Solve_video_playback_issues
    Not sure whether that is relevant here.

  • Mbook needs power button pressed multiple times to start up when on battery

    Hey all,
    Not sure if anyone's had this particular problem, but here goes:
    When on battery power, my Macbook does not power up properly--I have to press the power button 5,7, probably close to 10x sometimes before it goes on. Each time I press the button I can hear it begin to start up but then it shuts down.
    Anyone had a similar problem? Or care to speculate on a possible reason/way to fix it? Figured I'd ask before I take a trip to the Apple store.
    Thanks!!

    Check to see how many battery cycles you have on the battery in System Profiler. Apple-About this Mac-More Info...-Power. Let us know the number of cycles, condition, and maximum mAh.
    It couldn't hurt to try a SMC reset by turning off the machine, unplugging the magsafe, taking out the battery, and holding down the power button for 5 seconds.
    Next, reset the PRAM by putting everything back in, pressing the power button to turn it on, and holding down command-option-p-r until it chimes twice.
    Last, calibrate the battery (if you can get it working). Charge fully and let it sit charged for two hours. Then unplug the power and let it run down fully until it goes to sleep on its own and let it sit discharged for five hours. Last, charge it fully. Do this every 2-3 months to keep the battery working well otherwise keep it charging when possible. The goal is 2-3 cycles per week.

  • Dell Vostro 430, needs pushing power button multiple times before powering up

    Hi
    I had to push the power button twice for the system to power up for a long time now. For the last month or so, I need to push the power button up to 20 times for the system to start. Is this an issue with the power unit of the system and does anyone a solutions for this.
    Thanks

    Hi,
    Does this happen after leaving the system off all night or every time you start the machine?
    If it happens all the time, the power button assembly might have malfunctioned and will need to be replaced. When was the system purchased? You can try the following steps and check if it makes any difference
    Remove power cable
    Hold down power button for 10 seconds
    Plug back cable and try starting system.
    Revert with an update and we can look at further options.

  • Updates for Apps need to be downloaded multiple times to work

    I have iTunes 10.5.3 and when I download an update to an app, iTunes continues to show an update to that app as available.
    The download progresses normally and is shown as done when complete. However, the app is still shown in iTunes as having an update available.
    Usually if I re-download the update the app is updated and shown as done and will be synced OK, but sometimes I need to re-download the app 3 or 4 times to update.
    I have only started experiencing this issue since updating to iTunes 10.5.3 and OSX 10.7.3. I have performed all the usual housekeeping routines such as reinstalling iTunes, repairing disk permissions, clearing caches etc.
    Regards
    Mitch

    I was just about to post on the same subject.  I have the exact same thing happening in the last week.
    Don't think it has anything to do with 10.7.3 as I've been on that for some time ( as a registered dev).
    One of the annoying things for me was that one of the 'updates' was over 1Gb, asnd redownloading was a pain. 
    In some cases, If I delete the app, then re-download, the update notification goes away, but today with iGIZMO magazine that is not working.

  • Download the Update and run locally multiple times.

    Is it possible to get the (October 2gb update) bits locally from a machine instead of downloading on every machine i have with Win10? I see various folders, but not sure what would work. 2.5gig at a shot is a chunk.
    Thanks, Jon
    Jon

    Hi HupSkiDup (Jon),
    I was thinking a way to create a ISO file so that we can use this file to perform upgrade, but the method would be a bit of complicated.
    Here is my thought and steps.
    First, if we update our Windows 10 Technical Preview for Enterprise to 9860 build, we would get a install.esd file under C:\RecoveryImage folder.
    In Windows 8.1, here is a tool called update advisor, which would covert the esd file to ISO file, but in Windows 10 Technical Preview, there is no such thing. So my thought is to use the install.esd
    to create an install.wim or bootable ISO file.
    In my first thought, I want to sysprep an updated OS, but it failed without doubt, because we cannot sysprep a updated version OS. So, I choose to use Reset option. Install.esd would be recognized
    a compressed install.wim. when I use reset option in 9860 build, it reset the current OS, and I can sysprep this system now. After that, I was trying to use install.esd file directly in 9841 build:
    I copy the install.esd to a 9841 build OS, for example, I copy it to C:\RecoveryImage, and run
    reagentc.exe /setosimage /path C:\RecoveryImage /target c:Windows /Index 1 , it cannot reset the Windows OS. So I have to create an install.wim file for deployment.
    I use Reset option in 9860 build OS, when it is finished, run sysprep, it ran well, I can capture 9860 build wim file (WDS server capture or dism command). We rename it as install.wim.
    Use the captured install.wim to set recovery image in 9841 build (copy install.wim to C:\RecoveryImage, and run
    reagentc.exe /setosimage /path C:\RecoveryImage /target c:Windows /Index 1), 9841 build succeed upgrading to 9860 build via Reset and Refresh options.
    Refresh would upgrade without losing setting and data.
    Alex Zhao
    TechNet Community Support

  • How to run a webdynpro multiple times by passing different parameters each time and save webpages with parameter name?

    Hi Experts,
    I am a BW consultant and new to webdynpro. Not sure how to run RSO_METADATA_REPOSITORY multiple times and by passing different parameter values each time(either taken from an a standard BW table or user provided - anything is fine) and build web pages with parameter name. Need help with direction on where to start.
    Let me step back and explain my requirement:
    In BW we have an object called transformation.
    One way of generating documentation for transformation is highlight transformation and press F1. Then its documentation will be opened as a local web page.
    I need these web pages for all transformations. This is my requirment.
    I came to know that RSO_METADATA_REPOSITORY is beeing used to generate this web page.
    The web link is something like below:
    http://ubw05.xxx.com:8005/SAP/BW/DOC/METADATA/?page=BW_O_D&SystemID=BWPCLNT100&ClassID=TRFN&ID=0KHR6J65AIIUTCJZEC093K6XDFV909PB&objectVersion=A&sap-language=EN&sap-client=100
    When i run this link seperately(not by selecting transformation and pressing F1) i need to enter login credentials to BW system.
    My challenges is how do i pass login credentials and multiple transformation IDs to generate multipe web pages with each page named by transformation ID?
    WHere to start? First of all is RSO_METADATA_REPOSITORY Webdynpro JAVA or webdynpro ABAP or can i use anything?
    Since it is beeing opened as local webpages i assume it is webdynpro JAVa is that correct?
    Thanks,
    Raghu

    hello,
    might be a problem with the version you are using.
    regards,
    the oracle reports team

Maybe you are looking for

  • Home sharing won't play but airplay will.

    Setup: PC (Win 7) running Itunes 11.0.1.12 over WiFi N (2.4ghz) 3rd Gen Apple TV Ethernet connected directly to router. I've got the ATV to see my home sharing just fine.  When I go to play a movie/tv show it sticks on the loading screen for over 5 m

  • Problems migrating from MacBook Pro to MB Air

    I'm migrating from a MacBook Pro to a MB Air.  Both run OS X 10.7.5.  But Migration Assistants are different versions (4.1.2.vs. 1.0.1), and the machines cannot seem to communicate via ethernet.  Must I upgrade the older machine to a newer version of

  • Bapi or FM for T.Code CJIC

    Hi , I need a BAPI or FM For T.Code CJIC to upload the data, for this BDC is not working. Pls do the need full. Regards, Kranthi

  • Browser detection code for JSP ?

    Hi ,           Im new to JSP (in case the question wasn't a give-away!!).           I would like to know how to do a browser detect - becuase I have           1 CSS for IE and another for Netscape.           Is there some code snippet site that I can

  • Source Used Item Attribute

    Hi All, I am using HTML DB 2.0. I am a new user of HTMLDB. Please explain the difference between 2 Source Used Item Attribute 1. Always, replacing an existing value in session state 2. Only when current value in session state is null. If there is alr