How to loop a program?
i want it so that it will loop the whole program, ask the question over and over again until the user enters done.
Im new to java.
Thanks for all of the help
here is my main:
* Main.java
* Created on December 4, 2006, 9:27 AM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package magic_8ball;
import java.lang.reflect.Array;
import java.util.Random;
import java.util.Scanner;
* @author Bonsai
public class Main {
private static Class<?> String;
private static String groups;
private static String Scanner;
/** Creates a new instance of Main */
public Main() {
* @param args the command line arguments
public static void main(String[] args) {
System.out.println("Please ask the magic 8-ball your question");
Scanner in = new Scanner(System.in);
String enterNum = in.next();
Scanner = enterNum;
random_num newNum = new random_num();
Random myRandom = new Random();
int answer;
answer = myRandom.nextInt(16);
answer++;
answer++;
// System.out.println(answer);
//String[] groups = null;
String[] groups = new String[17];
groups[2] = "Please do not disturb me at this time!";
groups[3] = "Ask Again Later";
groups[4] = "Better Not Tell You Now";
groups[5] = "Concentrate and Ask Again";
groups[6] = "Don't Count on It!";
groups[7] = "It Is Certain";
groups[8] = "Most Likely";
groups[9] = "My Reply is No";
groups[10] = "My Sources Say No";
groups[11] = "Outlook Good";
groups[12] = "Outlook Not So Good";
groups[13] = "Reply Hazy, Try Again";
groups[14] = "Signs Point to Yes";
groups[15] = "Yes, Definitely";
groups[16] = "You May Rely On It";
System.out.println(groups[answer]);
while (Scanner == "done")
System.exit(0);
// TODO code application logic here
}Message was edited by:
Aten
aha, he beat me to it. Nevertheless,
* Main.java
* Created on December 4, 2006, 9:27 AM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package magic_8ball;
import java.lang.reflect.Array;
import java.util.Random;
import java.util.Scanner;
* @author Bonsai
public class Main {
private static Class<?> String;
private static String groups;
private static String Scanner;
private String again = "y";
/** Creates a new instance of Main */
public Main() {
* @param args the command line arguments
public static void main(String[] args) {
while(again.equalsIgnoreCase("y")){
System.out.println("Please ask the magic 8-ball your question");
Scanner in = new Scanner(System.in);
String enterNum = in.next();
Scanner = enterNum;
random_num newNum = new random_num();
Random myRandom = new Random();
int answer;
answer = myRandom.nextInt(16);
answer++;
answer++;
// System.out.println(answer);
//String[] groups = null;
String[] groups = new String[17];
groups[2] = "Please do not disturb me at this time!";
groups[3] = "Ask Again Later";
groups[4] = "Better Not Tell You Now";
groups[5] = "Concentrate and Ask Again";
groups[6] = "Don't Count on It!";
groups[7] = "It Is Certain";
groups[8] = "Most Likely";
groups[9] = "My Reply is No";
groups[10] = "My Sources Say No";
groups[11] = "Outlook Good";
groups[12] = "Outlook Not So Good";
groups[13] = "Reply Hazy, Try Again";
groups[14] = "Signs Point to Yes";
groups[15] = "Yes, Definitely";
groups[16] = "You May Rely On It";
System.out.println(groups[answer]);
while (Scanner == "done")
System.exit(0);
// TODO code application logic here
System.out.print("Try again? (y/n)");
Scanner input = new Scanner(System.in);
again = input.next();
Scanner = again;
}I'm unfamiliar with Scanner, but if it is what I think it is, this should do it.
All it does is make a while loop, and while again = "y", it will keep running the program and prompting them at the end to enter again once more
Message was edited by:
YodaOfDarkness
Similar Messages
-
Hello
How to make labview program to get average value of 200 reading from multimeter (I using using loop) to read voltage from mulmeter but I like to get average value of all of 200 reding how can I do that?
Thanks
Wee
Solved!
Go to Solution.Another idea with less programming - take advantage of the "free" array that comes with a Chart - i.e. the History Data.
1) Wire your DMM data to a Chart. (You can set the chart to invisible if you don't plan on using it in the GUI).
2) Set the Chart History Length to 200 (right click on the chart, click on Chart History Length...)
3) On the block diagram, use the History Data Property Node, wire it to Mean.vi, and you're done.
Easiest running average ever.
Message Edited by Broken Arrow on 04-07-2010 11:36 AM
Richard
Attachments:
EasyAvg.jpg 8 KB -
How to design a program on paper.
how to design a program on paper.
I am planning to create a small program, I want to do some paper work before writing the first line of code, what do I do and how do I do ?
should I learn UML and do it or any other thing ?
my question is to experience programmers, what do you do before writing the code for any program ?Most projects do very little other than collect information, process the information, and store the information.
1st - Identify what your project really is (project statement including well defined scope)
2nd - Identify resources
Data
Users
Equipment Needed
Developers available for the project
etc...
3rd - Do a reality check against your resources
4th - Aquire more resources as required or scale back project scope
5th - Get buy off from interested parites on your project definition and scope.
6th - loop back to 1 as need to attain a working definition and resources to complete the project.
(Notice: no code has been written yet--nor even thought about)
7th - Identify Data and Data Sources
8th - Define appropriate distribution of functionality across Tiers
9th - Assign teams for each or set phase of each for implementation purposes (according to project needs) Note: User Interfaces are always most complex -- assign your people accordingly.
10th - Identify data and processes specific to tier
11th - process flow models with data flow over lays
12th - design objects to implement process and facilitate data flow
13th - functionality review and buy off from clients
14th - loop back to 10 as needed
(Notice: no code yet)
15th - <here it is> code here
16th - debug (with code reviews)
17th - integrate
18th - debug (with code revies)
19th - loop back to 15 as needed
20th - alpha test (large integration)
21st - debug (with code reviews)
22nd - loop back to 20 as needed
23rd - beta and user trials
24th - user requested changes
25th - debug (with code reviews)
26th - loop back to 23 as needed
27th - user buy off
28th - project delivered
29th - wrap up and archive of documentation
30th - on going (life cycle) maintenance.
There ya go, that is about what I go through when desiging a project--the coding is a very very small part in comparison to the rest. Coding come to approximately 20% of a project. -
How to write a program to read any texts in any ABAP program?
Hi Experts,
How can I write a program to read specific coding section or any texts in any ABAP program?
For example, I want to wirte a program to count how many 'LOOP' and 'ENDLOOP' are in any other program.
Thanks!
Best regards,
HaoHi,
Follow the given below URL for the program to read another Program into an internal Table.
http://abap4.tripod.com/Upload_and_Download_ABAP_Source_Code.html
Once the Code is there in the Internal Table , you can do the necessary string search. -
How to close external programs?
Hi there,
in vbs is a command "ExtProgram(ExtProgramName, ExtProgramArg)" to
start external programs. But how to close external programs when
they finished its work? Is there a vbs-command for it? Is there a way
when calling "cmd.exe" with a proper parameter?
Martin BohmHello Martin!
Yes, with the tool 'tasklist' in the same directory.
The problem is that it is not easy to query from script. I tried it in the following script. Perhaps not perfect espacially because a command interpreter pop up every time you call the function.Option Explicit
If IsDIAdemRunning() Then
Call MsgBox( "At least one DIAdem is running!" )
Else
Call MsgBox( "No DIAdem at all!" )
End If
Function IsDIAdemRunning()
Dim oWshShell
Dim oExec
' Execute via Shell Object
Set oWshShell = CreateObject("WScript.Shell")
Set oExec = oWshShell.Exec( "C:\windows\system32\tasklist.exe /FI ""IMAGENAME eq DIAdem.exe""")
' wait until tasklist is finished
Do While oExec.Status = 0
Pause(1)
Loop
' no Standard Output -> no DIAdem running
IsDIAdemRunning = Len(oExec.StdOut.ReadAll) <> 0
End Function
A better solution might be possible via WMI.
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater? -
How to debug a program exit in a Workflow ?
Hi experts,
How to debug a program exit in a workflow when the workflow is triggered ?
thanks in advance
regards
AshwinIn 4.6c I did this by creating a function module and a table (zsm50_debug). In the table are just two fields: User name (key), and a flag (yes/no).
The function module:
FUNCTION zsm50_debug.
*"*"Local interface:
*" IMPORTING
*" REFERENCE(Z_DEBUG_USER) LIKE SY-UNAME
DATA: z_exit,
z_debug.
CLEAR: z_debug.
DATA: starttime TYPE t,
currenttime TYPE t,
time_passed TYPE i.
starttime = sy-uzeit.
* Check if debugging is switched on
SELECT SINGLE debug FROM zsm50_debug
INTO z_debug
WHERE uname = z_debug_user.
* Debugging is switched on:
IF z_debug = 'X'.
* Not an endless loop, but it will continue after approx. 1 minute...
* Plenty of time to go to SM50 to debug the program and continue!
DO.
* Change the value of z_exit to 'X' to exit the loop an stay in
* debug mode.
IF z_exit = 'X'.
EXIT.
ENDIF.
* To prevent an endless loop (if the user forgot that debugging was
* switched on in ZSM50_DEBUG, time is measured to allow the program
* to continue after 2 minutes
GET TIME FIELD currenttime.
time_passed = currenttime - starttime.
IF time_passed > 120.
WRITE: / '!!!==========================================!!!'.
WRITE: / '!!!DEBUGGING STILL SWITCHED ON IN ZSM50_DEBUG!!!'.
WRITE: / '!!! Program was delayed by two minutes !!!'.
WRITE: / '!!!==========================================!!!'.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDFUNCTION.
This FM reads the table and checks if the flag is switched on. If so, it loops for two minutes. After that, it continues regardless. If not flagged, it continues immediately.
This way, you can debug any program that is running in the background.
In every method I program I add this FM right in the beginning. With authorization for SM50, I can then debug the program (in production it may be difficult to get the correct server, if there are more). -
How to debug the program in background
hi
how to debug the program in backgroundHello everyone,
I often debug my programs via the sm50 transaction and it works very well (especially when you put the dummy loop ^ - ^ ). However we are confronted to a major problem when more than one user tries to debug. We get a message saying that the maximum number of users in the debugging mode has been reached!! Thus we each have to wait for our turn to debug our program. It's a real pain.
We've searched for a parameter to configure the number of users for the debugging mode but in vain
Has anyone else had this kind of problem? If yes, what do I need to do to correct it?
Any suggestion would be helpful as I am new to BW.
Thank you beforehand.
Regards,
Dimple -
How to loop at these 2 itabs?
Hi Champs,
In the mycontext tab, i am looping at two internal tables based on where condition. I need to filter data from my 2nd int table and put it out on the form. But somehow i am not bale to check the condition and as a a result i could see all the records of 2nd itab in one shot.
Can someone help me how to loop at these 2 tables?
thanks
DanyHi Champs,
In the mycontext tab, i am looping at two internal tables based on where condition. I need to filter data from my 2nd int table and put it out on the form. But somehow i am not bale to check the condition and as a a result i could see all the records of 2nd itab in one shot.
Can someone help me how to loop at these 2 tables?
thanks
Dany -
How to loop and read repeating table data of infoPath form in Visual studio workflow.
Hi,
I am trying to read info Path form repeating table data in Visual studio workflow.
could anyone elaborate me in brief how to loop through repeating table and read all rows value one by one in workflow.
any help would be more then welcome.
Thanks...Hi Rohan,
According to your description, my understanding is that you want to create a Visual Studio workflow to get data from info path repeating table.
I suggest you can submit Repeating Table to a SharePoint List and then you can create a .NET workflow to read data from the SharePoint List.
Here are some detailed articles for your reference:
Codeless submitting InfoPath repeating table to a SharePoint list
Create a Workflow using Visual Studio 2010
Best Regards
Zhengyu Guo
TechNet Community Support -
How to program a midi foot controller on Mainstage? Does anyone knows how to program the foot controller with exclusive solo channel in order not to dance "tip tap" while from clean guitar I go to crunch or solo? How to do this programming on Mainstage?
I basically managed to learn how to invert parameters which allows me to be as default in the clean guitar channel and if I switch the first button on the midi foot controller I switch to crunch, but at this point I tryied so hard to programm the second and third button to switch, only through a button in one step, to a third channel for distorsion or a 4th channel for solo guitar but I couldn't figured out how this work can be done!
I would appreciate if anyone could help or share this experience with others who are experiencing the same problem.
Cheers.
F.I cannot seem to get mainstage to recognize my FCB either. I am using IFCB. Anyone figure this out?
Thanks,
Eric -
Hi all.
I would like some help on how to create a program. Im still very new to the Labview program so any help would be greatful.
Now granted that, heres my issue, ive got an assignment for a class that i have no idea where to start.
Heres the assignment:
You have a discount coupon that gives you a ten cent per gallon discount up to 15 gallons.
You purchase regular gas which is priced at $3.56 a gallon, you give the clerk $30.00 to purchase that much in gas. After applying the discount, how much would you actually have to pay?
For the controls and indicators, i need to show the Amount Tendered, the Discount, Gallons purchased, the Final Price and Discount Amount.
As ive said above, i have no idea where to start with this.
THanks all.lorddd337 wrote:
Actually i dont have the math worked out as of yet since i have no idea how to do the math that will apply to the program.
Then you need to work out the math first. This has nothing to do with LabVIEW or programming.
For each terminal, decide if it is an input (something the user controls) or an output (something the program will calculate based on the values of the other controls). Have you done that?
lorddd337 wrote:
Also i dont know which tutorial would work for this.
Whatever you just learned in class is probably sufficient. Else start the tutorials in order to learn the basics.
LabVIEW Champion . Do more with less code and in less time . -
How to schedule a program in background after 5 or 10 sec
Hi All,
Can anyone tell me how to schedule a program after 5 or 10 sec in background after the transaction is completed.
It is not a custom transaction. I want to execute a Z program in background in a BADI
Regards
Yathish
Message was edited by:
Yathish GundlupetProgramattically? You can add this code to the end of your transaction(if it is custom, of course).
report zrich_0004 .
data: sdate type sy-datum,
stime type sy-uzeit,
l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount,
l_jobname like tbtcjob-jobname.
start-of-selection.
* Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
* Open Job
l_jobname = 'THIS_JOB'.
call function 'JOB_OPEN'
exporting
jobname = l_jobname
importing
jobcount = l_jobcount.
* Submit report to job
submit <your_program_name
via job l_jobname
number l_jobcount
to sap-spool without spool dynpro
spool parameters ls_params
and return.
* Kick job off 10 seconds from now.
sdate = sy-datum.
stime = sy-uzeit + 10.
* Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = l_jobname
sdlstrtdt = sdate
sdlstrttm = stime
Regards,
RIch Heilman -
How to run a program as an administrator from within a non-elevated command prompt?
I have a project that is going to be running on a kiosk, and the user that is running the kiosk software is going to be restricted. I have an alternate administrator account, but I cannot seem to figure out how to open my program running as this administrator
user. I have tried to use runas, like so:
runas /user:admin kiosk.exe
However, when I try to run this command, it asks me for the password of the administrator account and my program doesn't open correctly. It fails to open at all. If I change the run as to a start command, then the program executes fine so its
not a problem with my software.
Is there a way to pass a password parameter to runas so that it will not prompt for the password every time? If there is not, can someone think of another way for me to elevate my process to administrator without being logged in as one through the
command prompt?Hi KevinGEAR,
You want to allow the others without the administrator`s level to run this software and meanwhile the administrator is not logged in, right?
Here is an alternative solution :
1.To work with this solution, a built-in administrator account should be enabled and meanwhile you can create a standard account. The built-in administrator account is different from the administrator account you created.
To enable built-in administrator account:
Ways to Enable / Disable the Built-In Windows 7 Admin Account
http://social.technet.microsoft.com/wiki/contents/articles/3040.enable-disable-the-local-hidden-built-in-administrator-account-in-windows-7.aspx
2. Use the following code
runas /user:ComputerName\Administrator /savecred "Full path to program's exe file"
Here is a link for reference:
Elevated Program Shortcut - Create for Standard User
http://www.sevenforums.com/tutorials/193743-elevated-program-shortcut-create-standard-user.html
NOTE: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites.
Best Regards -
How to open labview program with Quit Labview function inside?
Hi Any idea how to open labview program with Quit Labview function inside?
I forgot to add and set the condition of the type for this program.
If the program is an application, it would close straight away.
If it is still labview work, it will go straight to editing program without closing.
So I need to recover, open it and make some changes.
Clement
Solved!
Go to Solution.Put the VI in a project and open it from there, then it shouldn't autorun. You can use App.kind property of application to decide whether to close or not.
/Y
LabVIEW 8.2 - 2014
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV -
How to loop through the "On My Mac" folders in mail?
Hi there - i am new to applescript, but am slowly working out how to use it.
I am stumped on how to write a rule that will move a message to a folder identified by a tag in a message (I am using MailTags).
I have script that will take the first tag and move the message to a mail folder in a fixed location (e.g. Archive/<tag name>) however I wanted to make it more generic by looping over all of my mail folders and finding one that matched the tag name.
However I am stumped on how to loop over all of my mail folder names - I have tried:
repeat with aFolder in (every mailbox of (mailbox for "ON MY MAC"))
and
repeat with aFolder in every mailbox of inbox
etc.
but none of these seem to work.
Is there some magic syntax to do this, so that I can do:
if (name of aFolder = msgTag) then
move oneMessage to mailbox (name of aFolder)
end if
TimYou don't necessarily need to assign a variable to the entire list in order to loop through them (unless you really want to) - for example:
tell application "Mail" to repeat with aFolder in (get mailboxes)
-- do stuff with aFolder
end repeat
There are several AppleScript resources, but the main ones I use are:
AppleScript Language Guide
AppleScript Tutorials at MacScripter.net
Maybe you are looking for
-
How to configure local disk on OVM Server as storage space to create VMs
Hello, We have installed OVM Server 3.1.1 on a machine that has 250 GB of Hard disk space [Single disk]. While installing used an option - Remove all partitions and create a new default partition layout. Around 4GB has been used and remaining 246 GB
-
Is there any sql command that can append some or all records from one table to another table? Or it has to use cursor to select data then insert into the distination table?
-
Multiple channel sampling and write file
Hei, I wrote a interface which is supposed to allow me to plot multiple channel and write all those datas in a file ; The problem is that : 1- not all the curves are plot in my graph (in fact just one is ploted). 2- At the same time it write in a fil
-
Adobe shockwave keeps crashing
I downloaded the new Flash player and i keep getting a message saying the add on shockwave is not responding and then it would close all my explorer windows. I recently switched to Google Chrome for a browser and it still crashes but doesn't close m
-
MBP shuts down randomly, ~5 times/day
Hi, I purchased my MBP in November 2011. Recently, it has been shutting itself randomly. At least a few times a day. Here is what from the problem report. Can anyone please help me? Interval Since Last Panic Report: 62443 sec Panics Since Last Repor