Need a comment for my program & questions.

Dear all,
I have just finished my simple project with LabView.
Actually, I have no much experience with LabView language.
Therefore I would like to hear your invaluable comments about using structure, variable, and some habits to write the program.
Please let me know if you find some bad thing or something should be escaped.
Regarding to my question, as you can see the status window(GPIB, RS-232, and Saving),
I would like to attach the common status window to main dialog with same structure (background).
But the status window couldn't seen in opening the window.
How can I modify it to see the status window in evey tab states?
Thank you in advance.
Lee
Attachments:
control_lsjun_v3_tem2.llb ‏283 KB

I think I would change the Tab control from the Windows style "Dialog Tab Control" to the standard LabVIEW style "Tab Control" - the Windows dialog style control does not fit in very well with the style/colouring of the LabVIEW control objects, and this is one reason why your status indicators don't integrate "visually" as well as they could.
I don't think it's possible to add an "always visible" part to a tab control, but there are one or two ways to "join" controls together...
1. You could simply use the "Group" front panel objects function in the editor taskbar - this will lock several independent objects together so that they move around together on the front panel (but are still seperate data terminals on the block diagram)
2. You could create a "Custom Control" or "Type Def" from several front panel objects - this way you could create a control which includes both a tab control and LED status indicators (etc, etc), all integrated into one single block diagram terminal/data structure (and is saved, so can be reused in other programs). This option might be a little cumbersome though, if you have many controls and indicators that you want to be included within your tab control (note: the control/indicators actually on the various tab pages do not have to be included in the custom tab type definition).
As regarding programming style - I think you need to try to not use "sequence structures" unless you really have to. I never use sequence structures except as a last resort. If by not using sequence structures the diagram becomes too large, then that is a sign that you might need to create mor sub VIs. Tip: All the sub VIs I create use the "error cluster" input/output, so it's allways possible to sequence sub VIs even when there is no data dependency.
Hope this helps.
Mark H.

Similar Messages

  • HT5312 Hi, i didn't put a rescue email and i need the answers for the security questions cuz i forgot them

    Hi, i didn't put a rescue email and i need the answers for the security questions cuz i forgot them

    If you can't remember your security questions / answers go to  Express Lane.
    select iTunes from the list, then iTunes store.        On the next screen select account Management.  There, select iTunes store account security and write that you would like to reset your security questions and / or answers.   You should get an eMail reply over the next 24 hours.

  • I need a solution for the security questions please ?? In the other hand i can't use the rescue email !! I need help .

    I need help for those security questions please !! I don't have a rescue email and even i don't know how to add it ! Please help me

    I didn't mean to give me an answer for the security questions i mean that i didn't remember the answers and i don't have a rescue email to send in it , i'm just ask for sloution to reset my security questions got it?

  • Need help with signing up for dev program - questions

    Greetings,
    I am planning on signing up for the dev program and I will be making a game to upload into the apple store. When I try sign up for the dev program/apple id, my country is not in the available list of countries. I am currently living in Mongolia and there is no itunes store available here. Would I be able to sign up for the dev program and develop/upload/sell?

    I am able to use the singapore store as I made this account using singapore as my region. If I do that with my dev account, will I not run into problems with billing/confirmation issues?

  • Need DME capability for payment program RFFOUS_C

    Hi,
    I am trying to create a DME file for Accounts Payable where we currently use the payment program RFFOUS_C. What do I need to do to get this done?
    Arne

    Hi again,
    Let me be more specific with what we need. We are currently using payment program RFFOUS_C for Accounts Payable to print checks. What we need now is a way to download the check data to a header and detail file in ACH format. Is there another payment program that we can use or otherwise what changes do I need to make to RFFOUS_C? We are using version 4.0B if that makes any difference.
    Thanks,
    Arne

  • Need DME cabability for payment program RFFOUS_C

    Hi,
    I am trying to create a DME file for Accounts Payable where we currently use the payment program RFFOUS_C. What do I need to do to get this done?
    Arne

    Hi Arne,
    Please check the following links.
    <a href="http://www.sap-img.com/financial/configure-the-data-medium-exchange-for-making-payments.htm">http://www.sap-img.com/financial/configure-the-data-medium-exchange-for-making-payments.htm</a>
    <a href="http://www.sap.cmich.edu/fihr/hr/productive-payroll.doc">http://www.sap.cmich.edu/fihr/hr/productive-payroll.doc</a>
    <a href="http://www.onepurdue.purdue.edu/contribute_pdf/ PY7-PayrollReportsandInterfaces.pdf">http://www.onepurdue.purdue.edu/contribute_pdf/ PY7-PayrollReportsandInterfaces.pdf</a>
    Hope This Info Helps YOU.
    <i>Reward Points If It Helps YOU.</i>
    Regards,
    Raghav

  • Need output format for trigger  program

    Hello everyone ;
    https://forums.oracle.com/message/11078921#11078921
    Above link is reference . It's also my own thread related to   this discussion.
    SQL> desc user_login
    Name                                                              Null?    Type
    USERNAME                                                                VARCHAR2(30)
    ISDBA                                                                          VARCHAR2(20)
    LOGIN_DATE                                                              DATE
    LOGIN_TIME                                                               VARCHAR2(15)
    LOGOUT_TIME                                                          VARCHAR2(15)
    EXTERNAL_NAME                                                     VARCHAR2(30)
    AUTHENTICATION_TYPE                                          VARCHAR2(30)
    HOST                                                                          VARCHAR2(20)
    Program for tracing user logon/logoff  details
    SQL> create or replace  trigger  tri_logon
    AFTER LOGON ON DATABASE
    BEGIN
    INSERT  INTO  user_login (username, isdba, external_name,
    authentication_type, HOST,  login_date , login_time)
    SELECT SYS_CONTEXT ('USERENV', 'SESSION_USER'),
    SYS_CONTEXT ('USERENV', 'ISDBA'),
      SYS_CONTEXT ('USERENV', 'EXTERNAL_NAME'),
      SYS_CONTEXT ('USERENV', 'AUTHENTICATION_TYPE'),
      SYS_CONTEXT ('USERENV', 'host'),
      SYSDATE, TO_CHAR (SYSDATE, 'HH24:MI:SS') FROM DUAL;
       END;
    Trigger  created.
    SQL> create or replace trigger tri_audit1
    2 BEFORE LOGOFf on database
    3   BEGIN
    4 insert into user_login (username, logout_time)
    5 (select user, TO_CHAR(SYSDATE, 'HH24:MM:SS') from dual);
    6 end;
    6 /
    Trigger  created.
    I got following output . Here i cannot insert logout_time on logout_time column.
    logout_time is dispalyed seperately please see last two output values  (CST01 ,  02:06:16)   and  user_name also displayed twice.  (don't  need )
    USERNAME   ISDBA   LOGIN_DAT   LOGIN_TIME   LOGOUT_TIME   EXTERNAL_NAME AUTHENTICATION_TYPE  HOST
    CST01           FALSE     21-JUN-13          02:06:11                                            oracle                            DATABASE                            linuxserver     CST01    02:06:16
    I want output following  below  format
    Expecting output  logout time  on  LOGOUT_TIME column  and   user_name  should be displayed once.
    USERNAME ISDBA LOGIN_DAT LOGIN_TIME   LOGOUT_TIME   EXTERNAL_NAME  AUTHENTICATION_TYPE HOST
    CST01      FALSE       20-JUN-13       13:06:34                                            oracle                       DATABASE                   LINUXSERVER
    thanks in advance ..

    8f953842-815b-4d8c-833d-f2a3dd51e602 wrote:
    Hello everyone ;
    https://forums.oracle.com/message/11078921#11078921
    Above link is reference . It's also my own thread related to   this discussion.
    SQL> desc user_login
    Name                                                              Null?    Type
    USERNAME                                                                VARCHAR2(30)
    ISDBA                                                                          VARCHAR2(20)
    LOGIN_DATE                                                              DATE
    LOGIN_TIME                                                               VARCHAR2(15)
    LOGOUT_TIME                                                          VARCHAR2(15)
    EXTERNAL_NAME                                                     VARCHAR2(30)
    AUTHENTICATION_TYPE                                          VARCHAR2(30)
    HOST                                                                          VARCHAR2(20)
    In addition to the myriad of other issues pointed out in this and your other -- essentially duplicate -- thread, why do you have separate columns for login_date and login_time?  A DATE datatype (which you have correctly defined for LOGIN_DATE carries both date and time elements.  You only need one column -- LOGIN_TIME -- populated with SYSDATE when the user logs in.  And LOGOUT_TIME should also be a DATE, populated with SYSDATE.  This alone points to several design flaws.
    1) DATE and TIME are not seperate elements.  In this application, the concept of 'time' has no meaning apart from the date, and a DATE data type, by definition, stores both date and time.
    2) keeping either date OR time in a varchar is asking for trouble.  Comparisons and math simply do not work as you expect.
    3) You don't have a date for LOGOUT, but suppose the user logs on at 2330 on Tuesday, and logs out at 0030 on Wednesday..
    Properly, you should only have two columns for this .. LOGON_TIME, defined as a DATE, and LOGOUT_TIME, defined as a date.
    Or possibly separate rows, one for LOGON and one for LOGOUT, both with a sessid to join them.
    Or better, and as I mentioned earlier, don't reinvent what AUDIT already does.  How much time have you spent on this (how much of your employers MONEY has been spent) when you could have solved the whole thing in 5 minutes with AUDIT?
    Program for tracing user logon/logoff  details
    SQL> create or replace  trigger  tri_logon
    AFTER LOGON ON DATABASE
    BEGIN
    INSERT  INTO  user_login (username, isdba, external_name,
    authentication_type, HOST,  login_date , login_time)
    SELECT SYS_CONTEXT ('USERENV', 'SESSION_USER'),
    SYS_CONTEXT ('USERENV', 'ISDBA'),
      SYS_CONTEXT ('USERENV', 'EXTERNAL_NAME'),
      SYS_CONTEXT ('USERENV', 'AUTHENTICATION_TYPE'),
      SYS_CONTEXT ('USERENV', 'host'),
      SYSDATE, TO_CHAR (SYSDATE, 'HH24:MI:SS') FROM DUAL;
       END;
    Trigger  created.
    SQL> create or replace trigger tri_audit1
    2 BEFORE LOGOFf on database
    3   BEGIN
    4 insert into user_login (username, logout_time)
    5 (select user, TO_CHAR(SYSDATE, 'HH24:MM:SS') from dual);
    6 end;
    6 /
    Trigger  created.
    I got following output . Here i cannot insert logout_time on logout_time column.
    logout_time is dispalyed seperately please see last two output values  (CST01 ,  02:06:16)   and  user_name also displayed twice.  (don't  need )
    USERNAME   ISDBA   LOGIN_DAT   LOGIN_TIME   LOGOUT_TIME   EXTERNAL_NAME AUTHENTICATION_TYPE  HOST
    CST01           FALSE     21-JUN-13          02:06:11                                            oracle                            DATABASE                            linuxserver     CST01    02:06:16
    I want output following  below  format
    Expecting output  logout time  on  LOGOUT_TIME column  and   user_name  should be displayed once.
    USERNAME ISDBA LOGIN_DAT LOGIN_TIME   LOGOUT_TIME   EXTERNAL_NAME  AUTHENTICATION_TYPE HOST
    CST01      FALSE       20-JUN-13       13:06:34                                            oracle                       DATABASE                   LINUXSERVER
    thanks in advance ..

  • I need the CDs for theses programs

    Hello, I am in need of these CDs, but I am also oversea, and because the Internet is so bad downloading is not a option. can I please get so help on getting theses
      iOS 10.7 lion
    iOS 10.8 mountain lion
    iOS 10.9 maverick
    iOS 10.10 Yosemite

    There are no disks for Mac OS X 10.8 or newer, and the thumbdrives for Mac OS X 10.7 are expensive and very hard to find; you may be able to find one on a site such as Amazon or eBay.
    (120429)

  • Help needed with swings for socket Programming

    Im working on a Project for my MScIT on Distributed Computing...which involves socket programming(UDP)....im working on some algorithms like Token Ring, Message Passing interface, Byzantine, Clock Syncronisation...i hav almost finished working on these algorithms...but now i wanna give a good look to my programs..using swings but im very new to swings...so can anyone help me with some examples involving swings with socket programming...any reference...any help would be appreciated...please help im running out of time..
    thanking u in advance
    anDy

    hi im Anand(AnDY),
    i hav lost my AnDY account..plz reply to this topic keeping me in mind :p

  • Need sample code for component programming

    I see samples page here:
    /docs/DOC-8061#61
    want to download "Web Dynpro Component Interface Definitions in Practice" sample, but only empty folders structure provided in download link.
    ("zip file" link )
    How to get full sample project according whay is written on this page?
    May be someone have this or like this sample ?
    (with some description than)
    I need to develop such type of application
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f07c3625-c971-2910-3a9c-ce131487f82c
    components, component interface usage, also for GP, but do not see code samples for this.
    Can you help with it?
    thanks
    Edited by: Vladimir Grigoryev on Aug 7, 2008 10:01 AM

    Hallo Vladimir,
    sorry me, but I have absolutely no idea what your problem really is. I provided you with all required information to download, import, build, deploy and run my Web Dynpro Java Sample application on "Component Interface Definitions in Practice". This material is enriched with in-depth technical documentation on the underlying concepts (you already linked to all these resources in the initial message of this thread; your second link is pointing to my powerpoint presentation on this sampel) to answer your last message about "but code is not sufficient".
    PLEASE read the [Readme.txt|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c0e4528f-c471-2910-66a0-dd459f975dc2] file to successfully install the local Web Dynpro DCs comprising the sample application metadata.
    NOTE: This sample is based on SAP NetWeaver 7.0, NOT on NetWeaver CE 7.1!!!
    I do not want to repeat all my descriptions in this mail thread.
    Regards, Bertram

  • BDC for MMRV program

    Hi Experts,
    h3 We need a BDC for MMRV program.
    1) The requirement is that we should be able to run this as a batch job with a Z transaction & the selection screen parameters should be a range of Company codes (MARV-BUKRS).
    2) The batch job should remove the flag ;Allow posting to previous period;(MARV-XRUEM) for this range of company codes entered in the selection screen.
    3) Currently we can enter only one company code in the standard MMRV transaction
    4) But we want to be able to enter a range of company codes.
    Can any one please suggest me whether it is possible or not. if possible how we can give ranges for company code in BDC.
    Thanks in advance,
    Dhanu

    Hi,
    Yes it is perfectly pssible. First make it work for one company code. Then repeat the same process for the next company code captured in selection screen say s_bukrs. Repeat this process till you are thr'u with all company codes from s_bukrs.
    I hope this helps,
    Regards
    Raju Chitale

  • Need idea on how to do question and answer program

    I want to create a troubleshooting program where it asks the user questions until its drilled down to an appropriate answer.
    I've done this with a web server before but I can't seem to figure out how to do it in a program without involving many many forms. Any ideas on how to do the UI?
    Thanks!

    Building an expert system is not a trivial process so for a commercial app you'll need to do some research. For an internal app you should probably use a database. For a school project you can get away with storing the data in a file that is loaded into
    memory (or simply building the data in memory directly).  In any case you'll need to define a table of questions.  If you support questions with fixed answers then you'll need a separate table for the answers associated with the questions. 
    If questions can be different types (as mentioned previously) then you'll also need to track the question type with the question.  For the relationship between questions you can go different ways depending upon your requirements. If question 1 with answer
    A goes to question 2 but answer B goes to question 3 then you can create a simple reference table that indicates what the next question is given the current question and answer, basically a state machine.  If a single answer opens a whole series of questions
    then you might do better to group the questions together and manage the transition between groups of questions.  It really depends upon your requirements. You'll want to research state machines to implement this though.
    On the UI side you really don't need to dynamically create anything.  The only thing that changes between questions is the text and possibly the answer format (if you support multiple questions). As I mentioned earlier you can create a separate container
    (Panel) for each question type and then show or hide the container based upon the type of question (from your database data).  This eliminates the need to dynamically create the UI.

  • For another program (WASY WGeo) after the working with PS CC I need a picture with the right colours in the end with 256 colours in 8 bit per picture - I still got it until yesterday. I don´t know what I´ve done wrong in PS CC but I´m still working in mod

    For another program (WASY WGeo) after the working with PS CC I need a picture with the right colours in the end with 256 colours in 8 bit per picture - I still got it until yesterday. I don´t know what I´ve done wrong in PS CC but I´m still working in mode with 8 bit RYB. I controlled my result with Irfan View: it´s a picture with 16,7 million colours and 56 bit pp.

    Topic or subject titles should be clear, pertinent and concise so that individual users can tell at a glance if they can help or not.
    That field is not for attempting to fit your entire question in there.
    Please keep this in mind next time you post.  Thank you.

  • Help  I have installed and reinstalled iTunes but it will not open.  I get an error telling me that windows DEP will not allow the program to run and i can not shut the DEP off for the program.  i need to reset my ipod touch and cant cause of this.

    I have tried to shut off the DEP for the program but it is not allowed.  I can't get to any of my music on my computer because of this.  I use windows vista and was able to use ITunes until the upgrade to 10.2.  now i can't even open the program and it is getting me very upset.  Please someone help me.

    Many thanks.
    That suggests that another application has stashed old QuickTime componentry in your system files.
    So just in case we'll go looking for older QuickTime componentry in the most common locations for it to be stashed.
    First we'll need to change some view settings.
    In your Start menu, open Computer.
    In your Organise menu, select Folder Options.
    In the View tab, make sure that "Show hidden files and folders" is selected, and Hide extensions for known file types is unchecked.
    Click OK.
    Now in Computer, open your C:\ drive (or whichever drive you have your operating system installed on).
    Open the "Windows" folder.
    If you have a 32-bit version of Windows, open the "System32" folder.
    If you have a 64-bit version of Windows, open the "SysWOW64" folder.
    What files and folders can you see in there with QuickTime in the title? (In a standard installation of Quicktime you should be seeing precisely two files... QuickTime.qts and QuickTimeVR.qtx ... and no QuickTime folders whatsoever.)

  • Need to create a driver class for a program i have made...

    hey guys im new to these forums and someone told me that i could get help on here if i get in a bind...my problem is that i need help creating a driver class for a program that i have created and i dont know what to do. i need to know how to do this is because my professor told us after i was 2/3 done my project that we need at least 2 class files for our project, so i need at least 2 class files for it to run... my program is as follows:
    p.s might be kinda messy, might need to put it into a text editor
    Cipher.java
    This program encodes and decodes text strings using a cipher that
    can be specified by the user.
    import java.io.*;
    public class Cipher
    public static void printID()
    // output program ID
    System.out.println ("*********************");
    System.out.println ("* Cipher *");
    System.out.println ("* *");
    System.out.println ("* *");
    System.out.println ("* *");
    System.out.println ("* CS 181-03 *");
    System.out.println ("*********************");
    public static void printMenu()
    // output menu
    System.out.println("\n\n****************************" +
    "\n* 1. Set cipher code. *" +
    "\n* 2. Encode text. *" +
    "\n* 3. Decode coded text. *" +
    "\n* 4. Exit the program *" +
    "\n****************************");
    public static String getText(BufferedReader input, String prompt)
    throws IOException
    // prompt the user and get their response
    System.out.print(prompt);
    return input.readLine();
    public static int getInteger(BufferedReader input, String prompt)
    throws IOException
    // prompt and get response from user
    String text = getText(input, prompt);
    // convert it to an integer
    return (new Integer(text).intValue());
    public static String encode(String original, int offset)
    // declare constants
    final int ALPHABET_SIZE = 26; // used to wrap around A-Z
    String encoded = ""; // base for string to return
    char letter; // letter being processed
    // convert message to upper case
    original = original.toUpperCase();
    // process each character of the message
    for (int index = 0; index < original.length(); index++)
    // get the letter and determine whether or not to
    // add the cipher value
    letter = original.charAt(index);
    if (letter >='A' && letter <= 'Z')
    // is A-Z, so add offset
    // determine whether result will be out of A-Z range
    if ((letter + offset) > 'Z') // need to wrap around to 'A'
    letter = (char)(letter - ALPHABET_SIZE + offset);
    else
    if ((letter + offset) < 'A') // need to wrap around to 'Z'
    letter = (char)(letter + ALPHABET_SIZE + offset);
    else
    letter = (char) (letter + offset);
    // build encoded message string
    encoded = encoded + letter;
    return encoded;
    public static String decode(String original, int offset)
    // declare constants
    final int ALPHABET_SIZE = 26; // used to wrap around A-Z
    String decoded = ""; // base for string to return
    char letter; // letter being processed
    // make original message upper case
    original = original.toUpperCase();
    // process each letter of message
    for (int index = 0; index < original.length(); index++)
    // get letter and determine whether to subtract cipher value
    letter = original.charAt(index);
    if (letter >= 'A' && letter <= 'Z')
    // is A-Z, so subtract cipher value
    // determine whether result will be out of A-Z range
    if ((letter - offset) < 'A') // wrap around to 'Z'
    letter = (char)(letter + ALPHABET_SIZE - offset);
    else
    if ((letter - offset) > 'Z') // wrap around to 'A'
    letter = (char)(letter - ALPHABET_SIZE - offset);
    else
    letter = (char) (letter - offset);
    // build decoded message
    decoded = decoded + letter;
    return decoded;
    // main controls flow throughout the program, presenting a
    // menu of options the user.
    public static void main (String[] args) throws IOException
    // declare constants
    final String PROMPT_CHOICE = "Enter your choice: ";
    final String PROMPT_VALID = "\nYou must enter a number between 1" +
    " and 4 to indicate your selection.\n";
    final String PROMPT_CIPHER = "\nEnter the offset value for a caesar " +
    "cipher: ";
    final String PROMPT_ENCODE = "\nEnter the text to encode: ";
    final String PROMPT_DECODE = "\nEnter the text to decode: ";
    final String SET_STR = "1"; // selection of 1 at main menu
    final String ENCODE_STR = "2"; // selection of 2 at main menu
    final String DECODE_STR = "3"; // selection of 3 at main menu
    final String EXIT_STR = "4"; // selection of 4 at main menu
    final int SET = 1; // menu choice 1
    final int ENCODE = 2; // menu choice 2
    final int DECODE =3; // menu choice 4
    final int EXIT = 4; // menu choice 3
    final int ALPHABET_SIZE = 26; // number of elements in alphabet
    // declare variables
    boolean finished = false; // whether or not to exit program
    String text; // input string read from keyboard
    int choice; // menu choice selected
    int offset = 0; // caesar cipher offset
    // declare and instantiate input objects
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader input = new BufferedReader(reader);
    // Display program identification
    printID();
    // until the user selects the exit option, display the menu
    // and respond to the choice
    do
    // Display menu of options
    printMenu();
    // Prompt user for an option and read input
    text = getText(input, PROMPT_CHOICE);
    // While selection is not valid, prompt for correct info
    while (!text.equals(SET_STR) && !text.equals(ENCODE_STR) &&
    !text.equals(EXIT_STR) && !text.equals(DECODE_STR))
    text = getText(input, PROMPT_VALID + PROMPT_CHOICE);
    // convert choice to an integer
    choice = new Integer(text).intValue();
    // respond to the choice selected
    switch(choice)
    case SET:
         // get the cipher value from the user and constrain to
    // -25..0..25
    offset = getInteger(input, PROMPT_CIPHER);
    offset %= ALPHABET_SIZE;
    break;
    case ENCODE:
    // get message to encode from user, and encode it using
    // the current cipher value
    text = getText(input, PROMPT_ENCODE);
    text = encode(text, offset);
    System.out.println("Encoded text is: " + text);
    break;
    case DECODE:
    // get message to decode from user, and decode it using
    // the current cipher value
    text = getText(input, PROMPT_DECODE);
    text = decode(text, offset);
    System.out.println("Decoded text is: " + text);
    break;
    case EXIT:
    // set exit flag to true
    finished = true ;
    break;
    } // end of switch on choice
    } while (!finished); // end of outer do loop
    // Thank user
    System.out.println("Thank you for using Cipher for all your" +
    " code breaking and code making needs.");
    }

    My source in code format...sorry guys :)
       Cipher.java
       This program encodes and decodes text strings using a cipher that
       can be specified by the user.
    import java.io.*;
    public class Cipher
       public static void printID()
          // output program ID
          System.out.println ("*********************");
          System.out.println ("*       Cipher      *");
          System.out.println ("*                   *");
          System.out.println ("*                          *");
          System.out.println ("*                   *");
          System.out.println ("*     CS 181-03     *");
          System.out.println ("*********************");
       public static void printMenu()
          // output menu
          System.out.println("\n\n****************************" +
                               "\n*   1. Set cipher code.    *" +
                               "\n*   2. Encode text.        *" +
                               "\n*   3. Decode coded text.  *" +
                               "\n*   4. Exit the program    *" +
                               "\n****************************");
       public static String getText(BufferedReader input, String prompt)
                                           throws IOException
          // prompt the user and get their response
          System.out.print(prompt);
          return input.readLine();
       public static int getInteger(BufferedReader input, String prompt)
                                           throws IOException
          // prompt and get response from user
          String text = getText(input, prompt);
          // convert it to an integer
          return (new Integer(text).intValue());
       public static String encode(String original, int offset)
          // declare constants
          final int ALPHABET_SIZE = 26;  // used to wrap around A-Z
          String encoded = "";           // base for string to return
          char letter;                   // letter being processed
          // convert message to upper case
          original = original.toUpperCase();
          // process each character of the message
          for (int index = 0; index < original.length(); index++)
             // get the letter and determine whether or not to
             // add the cipher value
             letter = original.charAt(index);
             if (letter >='A' && letter <= 'Z')          
                // is A-Z, so add offset
                // determine whether result will be out of A-Z range
                if ((letter + offset) > 'Z') // need to wrap around to 'A'
                   letter = (char)(letter - ALPHABET_SIZE + offset);
                else
                   if ((letter + offset) < 'A') // need to wrap around to 'Z'
                      letter = (char)(letter + ALPHABET_SIZE + offset);
                   else
                      letter = (char) (letter + offset);
             // build encoded message string
             encoded = encoded + letter;
          return encoded;
       public static String decode(String original, int offset)
          // declare constants
          final int ALPHABET_SIZE = 26;  // used to wrap around A-Z
          String decoded = "";           // base for string to return
          char letter;                   // letter being processed
          // make original message upper case
          original = original.toUpperCase();
          // process each letter of message
          for (int index = 0; index < original.length(); index++)
             // get letter and determine whether to subtract cipher value
             letter = original.charAt(index);
             if (letter >= 'A' && letter <= 'Z')          
                // is A-Z, so subtract cipher value
                // determine whether result will be out of A-Z range
                if ((letter - offset) < 'A')  // wrap around to 'Z'
                   letter = (char)(letter + ALPHABET_SIZE - offset);
                else
                   if ((letter - offset) > 'Z') // wrap around to 'A'
                      letter = (char)(letter - ALPHABET_SIZE - offset);
                   else
                      letter = (char) (letter - offset);
             // build decoded message
             decoded = decoded + letter;
          return decoded;
       // main controls flow throughout the program, presenting a
       // menu of options the user.
       public static void main (String[] args) throws IOException
         // declare constants
          final String PROMPT_CHOICE = "Enter your choice:  ";
          final String PROMPT_VALID = "\nYou must enter a number between 1" +
                                      " and 4 to indicate your selection.\n";
          final String PROMPT_CIPHER = "\nEnter the offset value for a caesar " +
                                       "cipher: ";
          final String PROMPT_ENCODE = "\nEnter the text to encode: ";
          final String PROMPT_DECODE = "\nEnter the text to decode: ";
          final String SET_STR = "1";  // selection of 1 at main menu
          final String ENCODE_STR = "2"; // selection of 2 at main menu
          final String DECODE_STR = "3"; // selection of 3 at main menu
          final String EXIT_STR = "4";  // selection of 4 at main menu
          final int SET = 1;            // menu choice 1
          final int ENCODE = 2;         // menu choice 2
          final int DECODE =3;          // menu choice 4
          final int EXIT = 4;           // menu choice 3
          final int ALPHABET_SIZE = 26; // number of elements in alphabet
          // declare variables
          boolean finished = false; // whether or not to exit program
          String text;              // input string read from keyboard
          int choice;               // menu choice selected
          int offset = 0;           // caesar cipher offset
          // declare and instantiate input objects
          InputStreamReader reader = new InputStreamReader(System.in);
          BufferedReader input = new BufferedReader(reader);
          // Display program identification
          printID();
          // until the user selects the exit option, display the menu
          // and respond to the choice
          do
             // Display menu of options
             printMenu(); 
             // Prompt user for an option and read input
             text = getText(input, PROMPT_CHOICE);
             // While selection is not valid, prompt for correct info
             while (!text.equals(SET_STR) && !text.equals(ENCODE_STR) &&
                     !text.equals(EXIT_STR) && !text.equals(DECODE_STR))       
                text = getText(input, PROMPT_VALID + PROMPT_CHOICE);
             // convert choice to an integer
             choice = new Integer(text).intValue();
             // respond to the choice selected
             switch(choice)
                case SET:
                // get the cipher value from the user and constrain to
                   // -25..0..25
                   offset = getInteger(input, PROMPT_CIPHER);
                   offset %= ALPHABET_SIZE;
                   break;
                case ENCODE:
                   // get message to encode from user, and encode it using
                   // the current cipher value
                   text = getText(input, PROMPT_ENCODE);
                   text = encode(text, offset);
                   System.out.println("Encoded text is: " + text);
                   break;
                case DECODE:
                   // get message to decode from user, and decode it using
                   // the current cipher value
                   text = getText(input, PROMPT_DECODE);
                   text = decode(text, offset);
                   System.out.println("Decoded text is: " + text);
                   break;
                case EXIT:
                   // set exit flag to true
                   finished = true ;
                   break;
             } // end of switch on choice
          } while (!finished); // end of outer do loop
          // Thank user
          System.out.println("Thank you for using Cipher for all your" +
                             " code breaking and code making needs.");
    }

Maybe you are looking for

  • Trouble removing a user from creative cloud for teams

    I am trying to remove a user from my team, however the X does not show the pop up menu with the option to remove them.  Also, when I click on any item on the left hand menu, nothing happens.

  • Event handler doesn't respond in IE

    Hi I have a peculiar problem. I've developed a really simple application. Its just one inputfield and a button. The inputfield is bound to a string in the context. In the wdDoInit of the controller I set the String to "Init". The buttons eventhandler

  • How to use my mac

    Where on the apple site are videos for getting around the computer and learning more than the basics. The other day a found myself learning how to enlarge the screen (hold control and 2 finger scroll) and how to create alias files instead of copying

  • Cisco ISE: 802.1x Timers Best Practices / Re-authentication Timers [EAP-TLS]

    Dear Folks, Kindly, suggest the best recommended values for the timers in 802.1x (EAP-TLS)... Should i keep default all or change or some of them? Also, what do we need reauthentication timers? Any benefit to use it? Does it prompt to users or became

  • Edit Page;Report;Enable CSV Output;Apply Changes;Page Not Found;wwv_flow

    Hi, We have a really annoying error in our application, whereby we are unable to save ANY changes to report attributes if Enable CSV Output is Yes. I have many pages with Enable CSV Output set to Yes, and when run, the pages can indeed be exported to