Help with switch statement

Hello I have a copy of my code below. Everything compiles fine its just when the code gets to the switch statement I get an error saying
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:819)
at java.util.Scanner.next(Scanner.java:1431)
at java.util.Scanner.nextInt(Scanner.java:2040)
at java.util.Scanner.nextInt(Scanner.java:2000)
at Sample.main(Sample.java:55)
Something is not working right when the user enters an integer expression. what can I do to fix this?
import java.util.*;
import java.io.*;
// Declare a public class
public class Sample {
     public static void main (String[] args){
     //Declare Variables
     float float0, float1;
     int int0, int1;
     String mathSign;
     char charMathSign;
     Scanner sc = new Scanner(System.in);
     //Ask user to Enter FLoating-Point Number Expression
     System.out.println("Enter a simple floating-point expression: ");
     float0 = sc.nextFloat();
     mathSign = sc.next ();
     float1 = sc.nextFloat();
     if(mathSign.equals("+"))
     System.out.println(float0 + " + " + float1 + " = " + (float0 + float1));     
     else if(mathSign.equals("-"))
     System.out.println(float0 + " - " + float1 + " = " + (float0 - float1));
     else if(mathSign.equals("*"))
     System.out.println(float0 + " * " + float1 + " = " + (float0 * float1));
     else if(mathSign.equals("/"))
     System.out.println(float0 + " / " + float1 + " = " + (float0 / float1));
     //Ask the user to enter a simple floating point expression
     System.out.println("Enter a simple integer expression: ");
     int0 = sc.nextInt ();
     charMathSign = mathSign.charAt(0);
     int1 = sc.nextInt ();
     switch (charMathSign)
          case '+': System.out.println(int0 + " + " + int1 + " = " + (int0 + int1));
          break;
          case '-': System.out.println(int0 + " - " + int1 + " = " + (int0 - int1));
          break;
          case '*': System.out.println(int0 + " * " + int1 + " = " + (int0 * int1));
          break;
          case '/': System.out.println(int0 + " / " + int1 + " = " + (int0 / int1));
          break;
[/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

{color:#000080}Duplicate posting, please post all responses at{color}{color:#0000ff}
http://forum.java.sun.com/thread.jspa?threadID=5219239{color}{color:#000080}
db{color}

Similar Messages

  • Help with Switch statements using Enums?

    Hello, i need help with writing switch statements involving enums. Researched a lot but still cant find desired answer so going to ask here. Ok i'll cut story short.
    Im writing a calculator program. The main problem is writing code for controlling the engine of calculator which sequences of sum actions.
    I have enum class on itself. Atm i think thats ok. I have another class - the engine which does the work.
    I planned to have a switch statement which takes in parameter of a string n. This string n is received from the user interface when users press a button say; "1 + 2 = " which each time n should be "1", "+", "2" and "=" respectively.
    My algorithm would be as follows checking if its a operator(+) a case carry out adding etc.. each case producing its own task. ( I know i can do it with many simple if..else but that is bad programming technique hence im not going down that route) So here the problem arises - i cant get the switch to successfully complete its task... How about look at my code to understand it better.
    I have posted below all the relevant code i got so far, not including the swing codes because they are not needed here...
    ValidOperators v;
    public Calculator_Engine(ValidOperators v){
              stack = new Stack(20);
              //The creation of the stack...
              this.v = v;          
    public void main_Engine(String n){
           ValidOperators v = ValidOperators.numbers;
                    *vo = vo.valueOf(n);*
         switch(v){
         case Add: add();  break;
         case Sub: sub(); break;
         case Mul: Mul(); break;
         case Div: Div(); break;
         case Eq:sum = stack.sPop(); System.out.println("Sum= " + sum);
         default: double number = Integer.parseInt(n);
                       numberPressed(number);
                       break;
                      //default meaning its number so pass it to a method to do a job
    public enum ValidOperators {
         Add("+"), Sub("-"), Mul("X"), Div("/"),
         Eq("="), Numbers("?"); }
         Notes*
    It gives out error: "No enum const class ValidOperators.+" when i press button +.
    It has nothing to do with listeners as it highlighted the error is coming from the line:switch(v){
    I think i know where the problem is.. the line "vo = vo.valueOf(n);"
    This line gets the string and store the enum as that value instead of Add, Sub etc... So how would i solve the problem?
    But.. I dont know how to fix it. ANy help would be good
    Need more info please ask!
    Thanks in advance.

    demo:
    import java.util.*;
    public class EnumExample {
        enum E {
            STAR("*"), HASH("#");
            private String symbol;
            private static Map<String, E> map = new HashMap<String, E>();
            static {
                put(STAR);
                put(HASH);
            public String getSymbol() {
                return symbol;
            private E(String symbol) {
                this.symbol = symbol;
            private static void put(E e) {
                map.put(e.getSymbol(), e);
            public static E parse(String symbol) {
                return map.get(symbol);
        public static void main(String[] args) {
            System.out.println(E.valueOf("STAR")); //succeeds
            System.out.println(E.parse("*")); //succeeds
            System.out.println(E.parse("STAR")); //fails: null
            System.out.println(E.valueOf("*")); //fails: IllegalArgumentException
    }

  • Help With Switch Statements

    Alrighty, so I have to do this assignment for my Java course, using a switch statement. The assignment is to have the user enter a number (1-5), and have the corresponding line of a poem be displayed. So if the user entered 1, "One two, buckle your shoe" would be displayed. This is what I have and it's giving me a huge problem:
    import java.util.Scanner;
    public class Poem
         public static void main(String[] args);
              Scanner kboard = new Scanner(System.in);
              System.out.println("Enter a number 1-5 (or 0 to quit).");
              int n = kboard.nextLine();
              switch (n);
                   case 1: System.out.println("One two, buckle your shoe.");
                   break;
                   case 2: System.out.println("Three four, shut the door.");
                   break;
                   case 3: System.out.println("Five six, pick up sticks.");
                   break;
                   case 4: System.out.println("Seven eight, lay them straight.");
                   break;
                   case 5: System.out.println("Nine ten, a big fat hen.");
                   break;
                   default: System.out.println("Goodbye.");
                   break;
    }This is giving me a HUGE string of errors. (Something like 45). I'm wracking my brain here trying to figure this out. Any help is greatly appreciated. Thanks!

    Well that solved a lot of the errors. Now all I get is this:
    --------------------Configuration: <Default>--------------------
    C:\JavaPrograms\Poem.java:8: <identifier> expected
    System.out.println("Enter a number 1-5 (or 0 to quit).");
    ^
    C:\JavaPrograms\Poem.java:8: illegal start of type
    System.out.println("Enter a number 1-5 (or 0 to quit).");
    ^
    C:\JavaPrograms\Poem.java:12: illegal start of type
    switch (n) {
    ^
    C:\JavaPrograms\Poem.java:12: <identifier> expected
    switch (n) {
    ^
    C:\JavaPrograms\Poem.java:14: orphaned case
    case 1: System.out.println("One two, buckle your shoe.");
    ^
    C:\JavaPrograms\Poem.java:30: class, interface, or enum expected
    }

  • Please i need help with switch from the us store to malaysian store how i can switch

    Please i need help with switch from the us store to malaysian store how i can switch

    Click here and follow the instructions to change the iTunes Store country.
    (82303)

  • Having problem with switch statement..please help

    here my question :
    GUI-based Pay Calculator
    A company pays its employees as executives (who receive a fixed weekly salary) and hourly workers (who receive a fixed hourly salary for the first 40 hours they work in a week, and 1.5 times their hourly wage for overtime worked).
    Each category of employee has its own paycode :
    ?     Paycode 1 for executives
    ?     Paycode 2 for hourly workers
    Write a GUI-based application to compute the weekly pay for each employee. Use switch to compute each employee?s pay based on that employee?s paycode.
    Use CardLayout layout manager to display appropriate GUI components. Obtain the employee name, employee paycode and other necessary facts from the user to calculate the employee?s pay based on the employee paycode:
    ?     For paycode 1, obtain the weekly salary.
    ?     For paycode 2, obtain the hourly salary and the number of hours worked.
    You may obtain other information which you think is necessary from the user.
    Use suitable classes for the GUI elements. (You can use javax.swing package or java.awt package for the GUI elements.)
    here my code so far :
    import java.awt.;*
    import java.awt.event.;*
    import javax.swing.;*
    *public class PayrollSystem implements ItemListener {*
    JPanel cards, JTextField, textField1, JLabel, label1;
    final static String EXECUTIVEPANEL = "1.EXECUTIVE";
    final static String HOURLYPANEL = "2.HOURLY WORKER";
    public void addComponentToPane(Container pane)
    *//Put the JComboBox in a JPanel to get a nicer look.*
    JPanel comboBoxPane = new JPanel(); //use FlowLayout
    JPanel userNameAndPasswordPane = new JPanel();
    *// User Name JLabel and JTextField*
    userNameAndPasswordPane.add(new JLabel("NAME"));
    JTextField textField1 = new JTextField(25);
    userNameAndPasswordPane.add(textField1);
    *String comboBoxItems[] = { EXECUTIVEPANEL, HOURLYPANEL };*
    JComboBox cb = new JComboBox(comboBoxItems);
    cb.setEditable(false);
    cb.addItemListener(this);
    comboBoxPane.add(cb);
    *//Create the "cards".*
    JPanel card1 = new JPanel();
    card1.add(new JLabel("WEEKLY SALARY"));
    card1.add(new JTextField(6));
    card1.add(new JLabel("TOTAL PAY"));
    card1.add(new JTextField(8));
    card1.add(new JButton("CALCULATE"));
    JPanel card2 = new JPanel();
    card2.add(new JLabel("HOURLY SALARY"));
    card2.add(new JTextField(6));
    card2.add(new JLabel("TOTAL HOURS WORK"));
    card2.add(new JTextField(8));
    card2.add(new JButton("CALCULATE"));
    *//Create the panel that contains the "cards".*
    cards= new JPanel(new CardLayout());
    cards.add(card1, EXECUTIVEPANEL);
    cards.add(card2, HOURLYPANEL);
    pane.add(comboBoxPane, BorderLayout.PAGE_START);
    pane.add(userNameAndPasswordPane, BorderLayout.CENTER);
    pane.add(cards, BorderLayout.PAGE_END);
    public void itemStateChanged(ItemEvent evt)
    CardLayout cl = (CardLayout)(cards.getLayout());
    cl.show(cards, (String)evt.getItem());
    ** GUI created*
    *private static void createAndShowGUI() {*
    *//Make sure we have nice window decorations.*
    JFrame.setDefaultLookAndFeelDecorated(true);
    *//Create and set up the window.*
    JFrame frame = new JFrame("GUI PAY CALCULATOR");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    *//Create and set up the content pane.*
    PayrollSystem demo = new PayrollSystem();
    demo.addComponentToPane(frame.getContentPane());
    *//Display the window.*
    frame.pack();
    frame.setVisible(true);
    *public static void main(String[] args) {*
    *//Schedule a job for the event-dispatching thread:*
    *//creating and showing this application's GUI.*
    *javax.swing.SwingUtilities.invokeLater(new Runnable() {*
    *public void run() {*
    createAndShowGUI();
    HOW CAN I PERFORM THE SWITCH STATEMENT INSIDE THIS CODE TO LET IT FULLY FUNCTIONAL..?
    I MUST PERFORM THE SWITCH STATEMENT LIKE IN THE QUESTION..
    PLEASE HELP ME..REALLY APPRECIATED...TQ

    hi
    A switch works with the byte, short, char, and int primitive data types. So you can simply give the
    switch (month) {
                case 1: 
                            System.out.println("January");
                            break;
                case 2:  {
                            System.out.println("February");
                             break;
                case 3: {
                              System.out.println("March");
                              break;
                             }where month controlls the flow
    moreover u can go to http://www.java-samples.com/java/free_calculator_application_in_java.htm
    for reference, just replace the if statement with switch with correct syntax

  • Problems with switch statement

    He everyone,
    i tried to built a page with 4 buttons. Each button is a symbol that contains 2 png´2 which are the the button Designs. If you click on  button 1 it should move on the screen. If you click it again it should moves back. and if you click on another button while button1 is active then button1 should move back to starting position and button 2 should move on screen.
    i use a switch statement and a variable.
    on composition ready i used
    sym.setVariable("current","");
    to set the Variable
    on each button(one of the png inside the symbols) i used:
    var current = sym.getComposition.getStage.getVariable("current");
    switch (current)
    case "" :
    sym.play("in");
    break;
    case button1 :
    sym.play("out");
    break;
    default :
    sym.getComposition.getStage.getSymbol(current).play("out");
    sym.play("in");
    break;
    ad each animation of the buttons are labels for the in and out animation. There are also triggers that change the variable current on the stage
    sym.getComposition.getStage.setVariable("current","button1");
    if i test it inside of a browser and click on one of the button nothing happens.
    i´m not sure what´s my mistake.
    can anyone help me?
    regards
    mr.monsen

    Hi,
    Some syntax errors in red:
    var current = sym.getComposition().getStage().getVariable("current");
    switch (current)
    case "" :
    sym.play("in");
    break;
    case "button1" :
    sym.play("out");
    break;
    default :
    sym.getComposition().getStage().getSymbol(current).play("out");
    sym.play("in");
    sym.getComposition().getStage().setVariable("current","button1");

  • Problem with switch-statement & ä, ö, ü

    Hi all,
    I am doing this Java online tutorial right now and have a problem with one of the exercises. Hopefully you can help me:
    I have to write a program that determines the number of consonants, vowels, punctuation characters, and spaces in an input line. I found a solution, but have two questions about it:
    •     I’m unable to calculate the amount of umlauts (ä, ö, ü). Somehow the program doesn’t recognize those characters. Why?
    •     In general I’m not very happy with this huge list of “cases”. How would you solve a problem like this? Is there a more convenient/elegant way?
    Thanks in advance!
    Write a program that determines the number of consonants, vowels, punctuation characters, and spaces in an input line.
    Read in the line into a String (in the usual way). Now use the charAt() method in a loop to access the characters one by one.
    Use a switch statement to increment the appropriate variables based on the current character. After processing the line, print out
    the results.
    import java.util.Scanner;
    class Kap43A1
      public static void main ( String[] args )
        String line;
        char letter;
        int total, countV=0, countC=0, countS=0, countU=0, countP=0;
        Scanner scan = new Scanner(System.in);
        System.out.println( "Please write a sentence " );
        line = scan.nextLine();
        total=line.length(); //Gesamtanzahl an Zeichen des Satzes
        for (int counter=0; counter<total; counter++)
          letter = line.charAt(counter); //ermitteln des Buchstabens an einer bestimmten Position des Satzes
          switch (letter)
            case 'A': case 'a':
            case 'E': case 'e':
            case 'I': case 'i':
            case 'O': case 'o':
            case 'U': case 'u':
              countV++;
              break;
            case 'B': case 'b': case 'C': case 'c': case 'D': case 'd': case 'F': case 'f': case 'G': case 'g': case 'H': case 'h':
            case 'J': case 'j': case 'K': case 'k': case 'L': case 'l': case 'M': case 'm': case 'N': case 'n': case 'P': case 'p':
            case 'Q': case 'q': case 'R': case 'r': case 'S': case 's': case 'T': case 't': case 'V': case 'v': case 'W': case 'w':
            case 'X': case 'x': case 'Y': case 'y': case 'Z': case 'z':
              countC++;
              break;
            case ' ':
              countS++;
              break;
            case ',': case '.': case ':': case '!': case '?':
              countP++;
              break;
            case 'Ä': case 'ä': case 'Ö': case 'ö': case 'Ü': case 'ü':
              countU++;
              break;
        System.out.println( "Total amount of characters:\t" + total );
        System.out.println( "Number of consonants:\t\t" + countC );
        System.out.println( "Number of vocals:\t\t" + countV );
        System.out.println( "Number of umlauts:\t\t" + countU );
        System.out.println( "Number of spaces:\t\t" + countS );
        System.out.println( "Number of punctuation chars:\t" + countP );
    }

    WRE wrote:
    •In general I’m not very happy with this huge list of “cases”. How would you solve a problem like this? Is there a more convenient/elegant way?I've been doing this a lot lately myself evaluating documents with 20 or so million words. Few tips:
    1. Regular expressions can vastly reduce the list of cases. For example you can capture all letters from a to z or A to Z as follows [a-zA-Z]. To match a single character in a String you can then make use of the Pattern and Matcher classes, and incorporate the regular expression. e.g.
      //Un-compiled code, may contain errors.
      private Pattern letterPattern = Pattern.compile("[a-zA-Z]");
      public int countNumberOfLettersInString(final String string) {
        int count = 0;
        Matcher letterMatcher = letterPattern.matcher(string);
        while(letterMatcher.find()) {
          count++;
        return count;
      }2. As mentioned above, Sets are an excellent choice. Simply declare a static variable and instantiate it using a static initializer block. Then loop over the String to determine if the character is in the given set. e.g.
      //Un-compiled code, may contain errors.
      private static Set<Character> macrons = new HashSet<Character>();
      static {
        macrons.add('ä');
        macrons.add('ö');
        macrons.add('ü');
      public int countNumberOfMacronsInString(final String string) {
        int count = 0;
        for(char c : string.toCharArray()) {
          if(macrons.contains(c) {
            count++;
        return count;
      }Mel

  • Need help with switch/case

    Thanks in advance.
    I read the tut on switch statements. My assignment is asking me to do something that is not detailed in that explanation ;
    I have a total of 5 case statements, 1-4 and a default statement. The instructions for them are as follows:
    Case 1: If the user enters a 1, display a message that informs users they are correct, as any input canbe saved as a String. Enter the break statement.
    Case 2: If the user enters a 2, parse the value into tryInt. Display as message that informs the users they are correct. Enter the break statement.
    Case 3. If they user enters a 3, parse the value into tryDouble. Display a message tha t informs users they are correct. Enter the break statement.
    Case 4: Set done equal to true. Enter code to display a closing message. Enter a break statement.
    Case default: throw a new NumberFormatException.;
    Here is the code
    import java.io.*;
    import javax.swing.JOptionPane.*;
    public class MyType1
         public static void main(String[] args)
              //declaring variables
              String strChoice, strTryString, strTryInt, strTryDouble;
              int choice, tryInt;
              double tryDouble;
              boolean done = false;
              //loop while not done
              while (!done)
                   try
                        choice = Integer.parseInt(strChoice);
                        switch(choice)
                             case 1:
                                  JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 2:
                                  choice = Integer.parseInt(tryInt); JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 3:
                                  choice = Double.parseDouble(tryDouble);
                                  JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 4:
                                  done = true; JOptionPane.showMessageDialog(null,"Goodbye!");
                                  break;
    As usual Im doing something wrong. Please help.

    Thanks for your input. The directions for the assignment tells me to first declare the variables.
    Begin a while(!done) loop to repeat as long as teh user does not click the Cancel button.
    Inside a try statement, enter code to display an input box with three choices.
    Type choice = Integer.parseInt(strChoice); on the next line to parse the value for the choice entered by the user.
    (HERE THE SWITCH STATEMENT WITH CAST STATEMENTS)
    Close the switch statement with brackets
    Create a catch statement.
    import java.io.*;
    import javax.swing.JOptionPane.*;
    public class MyType1
         public static void main(String[] args)
              //declaring variables
              String strChoice, strTryString, strTryInt, strTryDouble;
              int choice, tryInt;
              double tryDouble;
              boolean done = false;
              //loop while not done
              while (!done)
                   try
                        String message = "What is My Type:" + "\n\n1) String\n2)Integer\n3)double\n4)Quit the program\n\n";
                        choice = Integer.parseInt(strChoice);
                        //test for valid choice 1, 2, 3, or 4
                        if (choice<1 || choice>4) throw new NumberFormatException();
                        else done = true;
                        switch(choice)
                             case 1:
                                  JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 2:
                                  choice = Integer.parseInt(tryInt); JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 3:
                                  choice = Double.parseDouble(tryDouble);
                                  JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 4:
                                  done = true; JOptionPane.showMessageDialog(null,"Goodbye!");
                                  break;
                   catch (NumberFormat Exception e)
                        JOptionPane.showMessageDialog(null, "Please enter a 1, 2, 3 or 4:",  "Error", JOptionPane.INFORMATION_MESSAGE);
              }Typing this now, I see I dont have anything in my try statement entering code to display an input box with three choices.
    (PS. I know I would write a catch statement for the NumberFormatException, but why would I also write this exception in the case statement also??)

  • Help with if statement in cursor and for loop to get output

    I have the following cursor and and want to use if else statement to get the output. The cursor is working fine. What i need help with is how to use and if else statement to only get the folderrsn that have not been updated in the last 30 days. If you look at the talbe below my select statement is showing folderrs 291631 was updated only 4 days ago and folderrsn 322160 was also updated 4 days ago.
    I do not want these two to appear in my result set. So i need to use if else so that my result only shows all folderrsn that havenot been updated in the last 30 days.
    Here is my cursor:
    /*Cursor for Email procedure. It is working Shows userid and the string
    You need to update these folders*/
    DECLARE
    a_user varchar2(200) := null;
    v_assigneduser varchar2(20);
    v_folderrsn varchar2(200);
    v_emailaddress varchar2(60);
    v_subject varchar2(200);
    Cursor c IS
    SELECT assigneduser, vu.emailaddress, f.folderrsn, trunc(f.indate) AS "IN DATE",
    MAX (trunc(fpa.attemptdate)) AS "LAST UPDATE",
    trunc(sysdate) - MAX (trunc(fpa.attemptdate)) AS "DAYS PAST"
    --MAX (TRUNC (fpa.attemptdate)) - TRUNC (f.indate) AS "NUMBER OF DAYS"
    FROM folder f, folderprocess fp, validuser vu, folderprocessattempt fpa
    WHERE f.foldertype = 'HJ'
    AND f.statuscode NOT IN (20, 40)
    AND f.folderrsn = fp.folderrsn
    AND fp.processrsn = fpa.processrsn
    AND vu.userid = fp.assigneduser
    AND vu.statuscode = 1
    GROUP BY assigneduser, vu.emailaddress, f.folderrsn, f.indate
    ORDER BY fp.assigneduser;
    BEGIN
    FOR c1 IN c LOOP
    IF (c1.assigneduser = v_assigneduser) THEN
    dbms_output.put_line(' ' || c1.folderrsn);
    else
    dbms_output.put(c1.assigneduser ||': ' || 'Overdue Folders:You need to update these folders: Folderrsn: '||c1.folderrsn);
    END IF;
    a_user := c1.assigneduser;
    v_assigneduser := c1.assigneduser;
    v_folderrsn := c1.folderrsn;
    v_emailaddress := c1.emailaddress;
    v_subject := 'Subject: Project for';
    END LOOP;
    END;
    The reason I have included the folowing table is that I want you to see the output from the select statement. that way you can help me do the if statement in the above cursor so that the result will look like this:
    emailaddress
    Subject: 'Project for ' || V_email || 'not updated in the last 30 days'
    v_folderrsn
    v_folderrsn
    etc
    [email protected]......
    Subject: 'Project for: ' Jim...'not updated in the last 30 days'
    284087
    292709
    [email protected].....
    Subject: 'Project for: ' Kim...'not updated in the last 30 days'
    185083
    190121
    190132
    190133
    190159
    190237
    284109
    286647
    294631
    322922
    [email protected]....
    Subject: 'Project for: Joe...'not updated in the last 30 days'
    183332
    183336
    [email protected]......
    Subject: 'Project for: Sam...'not updated in the last 30 days'
    183876
    183877
    183879
    183880
    183881
    183882
    183883
    183884
    183886
    183887
    183888
    This table is to shwo you the select statement output. I want to eliminnate the two days that that are less than 30 days since the last update in the last column.
    Assigneduser....Email.........Folderrsn...........indate.............maxattemptdate...days past since last update
    JIM.........      jim@ aol.com.... 284087.............     9/28/2006.......10/5/2006...........690
    JIM.........      jim@ aol.com.... 292709.............     3/20/2007.......3/28/2007............516
    KIM.........      kim@ aol.com.... 185083.............     8/31/2004.......2/9/2006.............     928
    KIM...........kim@ aol.com.... 190121.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190132.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190133.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190159.............     2/13/2006.......2/14/2006............923
    KIM...........kim@ aol.com.... 190237.............     2/23/2006.......2/23/2006............914
    KIM...........kim@ aol.com.... 284109.............     9/28/2006.......9/28/2006............697
    KIM...........kim@ aol.com.... 286647.............     11/7/2006.......12/5/2006............629
    KIM...........kim@ aol.com.... 294631.............     4/2/2007.........3/4/2008.............174
    KIM...........kim@ aol.com.... 322922.............     7/29/2008.......7/29/2008............27
    JOE...........joe@ aol.com.... 183332.............     1/28/2004.......4/23/2004............1585
    JOE...........joe@ aol.com.... 183336.............     1/28/2004.......3/9/2004.............1630
    SAM...........sam@ aol.com....183876.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183877.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183879.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183880.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183881.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183882.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183883.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183884.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183886.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183887.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183888.............3/5/2004.........3/8/2004............     1631
    PAT...........pat@ aol.com.....291630.............2/23/2007.......7/8/2008............     48
    PAT...........pat@ aol.com.....313990.............2/27/2008.......7/28/2008............28
    NED...........ned@ aol.com.....190681.............4/4/2006........8/10/2006............746
    NED...........ned@ aol.com......95467.............6/14/2006.......11/6/2006............658
    NED...........ned@ aol.com......286688.............11/8/2006.......10/3/2007............327
    NED...........ned@ aol.com.....291631.............2/23/2007.......8/21/2008............4
    NED...........ned@ aol.com.....292111.............3/7/2007.........2/26/2008............181
    NED...........ned@ aol.com.....292410.............3/15/2007.......7/22/2008............34
    NED...........ned@ aol.com.....299410.............6/27/2007.......2/27/2008............180
    NED...........ned@ aol.com.....303790.............9/19/2007.......9/19/2007............341
    NED...........ned@ aol.com.....304268.............9/24/2007.......3/3/2008............     175
    NED...........ned@ aol.com.....308228.............12/6/2007.......12/6/2007............263
    NED...........ned@ aol.com.....316689.............3/19/2008.......3/19/2008............159
    NED...........ned@ aol.com.....316789.............3/20/2008.......3/20/2008............158
    NED...........ned@ aol.com.....317528.............3/25/2008.......3/25/2008............153
    NED...........ned@ aol.com.....321476.............6/4/2008.........6/17/2008............69
    NED...........ned@ aol.com.....322160.............7/3/2008.........8/21/2008............4
    MOE...........moe@ aol.com.....184169.............4/5/2004.......12/5/2006............629
    [email protected]/27/2004.......3/8/2004............1631
    How do I incorporate a if else statement in the above cursor so the two days less than 30 days since last update are not returned. I do not want to send email if the project have been updated within the last 30 days.
    Edited by: user4653174 on Aug 25, 2008 2:40 PM

    analytical functions: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions2a.htm#81409
    CASE
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/02_funds.htm#36899
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/04_struc.htm#5997
    Incorporating either of these into your query should assist you in returning the desired results.

  • Help with If statement please

    Hi,
    First Special thanks to Kglad for the help with the AS1 to AS3 conversion.
    I've been able to link up my buttons to play a different frames of the movie. this was my novice way of finally getting the programming to work.
    In frame 95 I have
    var myLoader:Loader = new Loader();
    addChild(myLoader); var url:URLRequest = new URLRequest("page1.swf");
    myLoader.load(url);
    in frame 165:
    var myLoader1:Loader = new Loader();
    addChild(myLoader1); var url1:URLRequest = new URLRequest("page1.swf");
    myLoader1.load(url1);
    My buttons link to 116 which plays a frame and loads ^
    in frame 226: removeChild(myLoader).
    But if the user has looped back into home from another part in the movie clip then it would need to remove myLoader1 instead of myLoader.
    I'm guessing there is some really dynamic way to solve the programatic nightmare i'm developing, but I'm really novice.
    So what i need is an if statement for frame 226
    That would do something:
    if(myLoader <> null
         removeChild(myLoader)
    else(
    removechild(myLoader1)
    Anyone have a method for this?

    yes, you can use the same urlrequest but just change its url property:
    // initialize, for example in frame 1.  this is done once and never again:
    var loader:Loader=new Loader();
    var urlR:URLRequest=new URLRequest();
    //  then in frame 2, for example:
    urlR.url="page1.swf";
    loader.load(urlR);
    //  in frame 20, for example:
    urlR.url="page2.swf";
    loader.load(urlR);
    // in frame 30, for example:
    urlR.url="page3.swf";
    loader.load(urlR);
    //etc.  if you're loading any swfs that play streams (sound or video), you'll want to add some code to this.

  • Problem with switch statement

    Here's my dilemma,
    I'm trying to write a program that takes a user input ZIP Code and then outputs the geographical area associated with that code based on the first number. My knowledge of Java is very, very basic but I was thinking that I could do it with the charAt method. I can get the input fine and isolate the the first character but for some reason the charAt method is returning a number like 55 (that's what I get when it starts with 7). Additionally, to use the charAt my input has to be a String and I can't use a String with the switch statement. To use my input with the Switch statement I have to make the variable an int. When I do that however, I can't use the charAt method to grab the first digit. I'm really frustrated and hope someone can point me in the right direction.
    Here's what I have so far:
    import java.util.Scanner;
    public class ZipCode
         public static void main(String[] args)
              // Get ZIP Code
              int zipCodeInput;
              Scanner stdIn = new Scanner(System.in);
              System.out.print("Please enter a ZIP Code: ");
              zipCodeInput = stdIn.nextInt();
              // Determine area of residence
              switch (zipCodeInput)
                   case 0: case 2: case 3:
                        System.out.println(zipCodeInput + " is on the East Coast");
                        break;
                   case 4: case 5: case 6:
                        System.out.println(zipCodeInput + " is in the Central Plains area");
                        break;
                   case 7:
                        System.out.println(zipCodeInput + " is in the South");
                        break;
                   case 8: case 9:
                        System.out.println(zipCodeInput + " is int he West");
                        break;
                   default:
                        System.out.println(zipCodeInput + " is an invalid ZIP Code");
                        break;
    }

    Fmwood123 wrote:
    Alright, I've successfully isolated the first number in the zip code by changing int zipCodeChar1 into char zipCodeChar1. Now however, when I try to run that through the switch I get the default message of <ZIP> is an invalid ZIP Code. I know that you said above that switch statements were bad so assume this is purely academic at this point. I'd just like to know why it's not working.
    import java.util.Scanner;
    public class ZipCode
         public static void main(String[] args)
              // Get ZIP Code
              String zipCodeInput;
              char zipCodeChar1;
              Scanner stdIn = new Scanner(System.in);
              System.out.print("Please enter a ZIP Code: "); // Input of 31093
              zipCodeInput = stdIn.nextLine();
              System.out.println("zipCodeInput is: " + zipCodeInput); // Retuns 31093
              zipCodeChar1 = zipCodeInput.charAt(0);
              System.out.println("zipCodeChar1 is: " + zipCodeChar1); // Returns 3
              // Determine area of residence
              switch (zipCodeChar1)
                   case 0: case 2: case 3:
                        System.out.println(zipCodeInput + " is on the East Coast");
                        break;
                   case 4: case 5: case 6:
                        System.out.println(zipCodeInput + " is in the Central Plains area");
                        break;
                   case 7:
                        System.out.println(zipCodeInput + " is in the South");
                        break;
                   case 8: case 9:
                        System.out.println(zipCodeInput + " is int he West");
                        break;
                   default:
                        System.out.println(zipCodeInput + " is an invalid ZIP Code");
                        break;
    When you print the char '7' as a character you will see the character '7', but char is really a numeric type: think of it as unsigned short. To convert '0'...'9' to the numbers 0...9, do the math:
    char ch = ...
    int digit = ch - '0';edit: or give your cases in terms of char literals:
    case '0': case '2': case '3':

  • Help with return statements

    Can someone explain to me what a return statement does exactly and how I would use it to return a value in the follwoing type of program.
    Its a array making program that allows up to 25 values with the value 0 stopping the method. I need to be able to display the how many usable values the user input (anywhere from 1-25).
    To do this I need to use a return statement, correct? if so, how do utilize it correctly if it is nesasary I will post the code itself.

    Heres what I have for the code...
    To simplify amounbt of typing(I wrote program in telnet) The beginning is a set of options using switch statement. 4 choices, 1)new data. 2) list the data 3) change the data and 4) exit.
    For the new data I need to have the user input up to 25 values or stop at any time by entering 0. the values also cannot be greater than 12000 or less than -12000. it should also return the number of usable values in the array. The return statement is what I am having trouble with.
    Code...
    static int NewData(double a[]) //This part is not changeable
    {   int 1;
    for(i=0; i<25; i++)
    {  System.out.print("Enter Element"+(i +1)+ "- ");
    a=MyInput.readDouble();
    if (a[i]>12000 || a[i]<-12000)
    {System.out.println("the last value is not valid");
                                 break;}
    if (a[i]==0)
    break;
    } return i;
    As of right now the method functions as is but two things need to be changed or added. If possible the program should now break if the user inputs an element greater than 12000 or less than -12000, it should just reset to the integer they were on. Also, how do I get the return value to display something? have i used it correctly to show the number of usable values ithe user entered?

  • *********H E L P*********with SWITCH STATEMENT

    I am creating a class that extends object. I am using JOptionPane for input. I have a switch statement that I am using to call other methods, such as displaying a flag using GraphicsPen. Everything works great except when the switch calls the flag method and displays the flag, I can't close the flag until I end the switch method. I have a " for(;;) " statement that encloses the main method so the switch method will continue after each iteration.*********HELP*********PLEASE!*****************

    class switchflags extends Object //class declaration
    public static void main (String[]args) //main method
    final String TITLE = "SWITCH"; //title for dialogs
    for (;;) //loop
    String switchstring = JOptionPane.showInputDialog //dialog for input
    (null,"Select which program you want to use from below.\n\n"+
    "*******Press enter when finished*******\n\n"+
    "Enter 0 : to Quit\n"+
    "Enter 1 : to see the Dutch Flag\n"+
    "Enter 2 : to see the Mauritius Flag\n"+
    "Enter 3 : to see the Italian Flag\n"+
    "Enter 4 : to see the Norwegian Flag\n"+
    "Enter 5 : to calculate Fibonacci number (n)\n"+
    "Enter 6 : to calculate Miles Per Gallon\n\n",TITLE,JOptionPane.INFORMATION_MESSAGE);
    int switchint = Integer.parseInt(switchstring); //convert string to a integer
    if (switchint == 0) //exit if 0 was entered
    JOptionPane.showMessageDialog
    (null,"Thanks for using this program.\nHave a nice day!",TITLE,JOptionPane.PLAIN_MESSAGE);
    System.exit(0); //end program
    else if (switchint < 0) //show error for invalid numbers less than zero
    JOptionPane.showMessageDialog
    (null,"*******ERROR*******\n\nEnter a number\nbetween (1 - 6).\n\nOr (0) to Quit.\n\n",
    TITLE,JOptionPane.ERROR_MESSAGE);
    else if (switchint > 6) //show error for invalid numbers greater than six
    JOptionPane.showMessageDialog
    (null,"*******ERROR*******\n\nEnter a number\nbetween (1 - 6).\n\nOr (0) to Quit.\n\n",
    TITLE,JOptionPane.ERROR_MESSAGE);
    switch (switchint) //test variable that was entered
    case 1: DutchFlag1.start(); //display Dutch flag
    break;
    case 2: mauritius.start(); //display Mauritius flag
    break;
    case 3: italy.start(); //display Italy flag
    break;
    case 4: norway.start(); //display Norway flag
    break;
    case 5: FIBONACCI.start(); //run Fibonacci program
    break;
    case 6: MPG.start(); //run MPG program
    break;

  • Help with if statement for a beginner.

    Hello, I’m new to the dev lark and wondered if someone could point me in the right direction.
    I have the following (working!) app that lets users press a few buttons instead of typing console commands (please do not be too critical of it, it’s my first work prog).
    //DBS File send and Receive app 1.0
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import java.applet.Applet;
    public class Buttons extends JFrame
         public Buttons()
              super("DBS 2");          
              JTextArea myText = new JTextArea   ("Welcome to the DBS application." +
                                                           "\n" +
                                                           "\n\n1. If you have received an email informing you that the DBS is ready to dowload please press the \"Receive DBS\" button." +
                                                           "\n" +
                                                           "\n1. Once this has been Received successfully please press the \"Prep File\" button." +
                                                           "\n\n2. Once the files have been moved to their appropriate locations, please do the \"Load\" into PAS." +
                                                           "\n\n3. Once the \"Load\" is complete, do the \"Extract\"." +
                                                           "\n\n4. When the \"Extract\" has taken place please press the \"File Shuffle\" button." +
                                                           "\n\n5. When the files have been shuffled, please press the \"Send DBS\" Button." +
                                                           "\n\nJob done." +
                                                           "\n", 20,50);
              JPanel holdAll = new JPanel();
              JPanel topPanel = new JPanel();
              JPanel bottomPanel = new JPanel();
              JPanel middle1 = new JPanel();
              JPanel middle2 = new JPanel();
              JPanel middle3 = new JPanel();
              topPanel.setLayout(new FlowLayout());
              middle1.setLayout(new FlowLayout());
              middle2.setLayout(new FlowLayout());
              middle3.setLayout(new FlowLayout());
              bottomPanel.setLayout(new FlowLayout());
              myText.setBackground(new java.awt.Color(0, 0, 0));     
              myText.setForeground(new java.awt.Color(255,255,255));
              myText.setFont(new java.awt.Font("Times",0, 16));
              myText.setLineWrap(true);
              myText.setWrapStyleWord(true);
              holdAll.setLayout(new BorderLayout());
              topPanel.setBackground(new java.awt.Color(153, 101, 52));
              bottomPanel.setForeground(new java.awt.Color(153, 0, 52));
              holdAll.add(topPanel, BorderLayout.CENTER);
              topPanel.add(myText, BorderLayout.NORTH);
              setSize(700, 600);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              getContentPane().add(holdAll, BorderLayout.CENTER);
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
              final JButton receiveDBS = new JButton("Receive DBS"); //marked as final as it is called in an Inner Class later
              final JButton filePrep = new JButton("Prep File");
              final JButton fileShuffle = new JButton("File Shuffle");
              final JButton sendDBS = new JButton("Send DBS");
              JButton exitButton = new JButton("Exit");
    //          JLabel statusbar = new JLabel("Text here");
              receiveDBS.setFont(new java.awt.Font("Arial", 0, 25));
              filePrep.setFont(new java.awt.Font("Arial", 0, 25));
              fileShuffle.setFont(new java.awt.Font("Arial", 0, 25));
              sendDBS.setFont(new java.awt.Font("Arial", 0, 25));
              exitButton.setBorderPainted ( false );
              exitButton.setMargin( new Insets ( 10, 10, 10, 10 ));
              exitButton.setToolTipText( "EXIT Button" );
              exitButton.setFont(new java.awt.Font("Arial", 0, 20));
              exitButton.setEnabled(true);  //Set to (false) to disable
              exitButton.setForeground(new java.awt.Color(0, 0, 0));
              exitButton.setHorizontalTextPosition(SwingConstants.CENTER); //Don't know what this does
              exitButton.setBounds(10, 30, 90, 50); //Don't know what this does
              exitButton.setBackground(new java.awt.Color(153, 101, 52));     
              topPanel.add(receiveDBS);
              middle1.add(filePrep);
              middle2.add(exitButton);
              middle3.add(fileShuffle);
              bottomPanel.add(sendDBS);
              receiveDBS.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        if (ae.getSource() == receiveDBS);
                        try
                             Runtime.getRuntime().exec("cmd.exe /c start c:\\DBS\\ReceiveDBSfile.bat");
                        catch(Exception e)
                             System.out.println(e.toString());
                             e.printStackTrace();
              filePrep.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        if (ae.getSource() == filePrep);
                        try
                             Runtime.getRuntime().exec("cmd.exe /c start c:\\DBS\\filePrep.bat");
                        catch(Exception e)
                             System.out.println(e.toString());
                             e.printStackTrace();
              exitButton.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        System.exit(0);
              fileShuffle.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        if (ae.getSource() == fileShuffle);
                        try
                             Runtime.getRuntime().exec("cmd.exe /c start c:\\DBS\\fileShuffle.bat");
                        catch(Exception e)
                             System.out.println(e.toString());
                             e.printStackTrace();
              sendDBS.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        if (ae.getSource() == sendDBS);
                        try
                             Runtime.getRuntime().exec("cmd.exe /c start c:\\DBS\\sendDBSFile.bat");
                        catch(Exception e)
                             System.out.println(e.toString());
                             e.printStackTrace();
              c.add(receiveDBS);
              c.add(filePrep);
              c.add(fileShuffle);
              c.add(sendDBS);
              c.add(exitButton);
    //          c.add(statusbar);
         public static void main(String args[])
              Buttons xyz = new Buttons();
              xyz.setVisible(true);
         }What I would like help with is the following…
    I would like output to either a JLabel or JTextArea to appear if a file appears on the network. Something along these lines…
    If file named nststrace*.* is in \\[network path] then output “Download successful, please proceed.”
    btw I have done my best to search this forum for something similar and had no luck, but I am looking forward to Encephalopathic’s answer as he/she has consistently made me laugh with posted responses (in a good way).
    Thanks in advance, Paul.

    Hospital_Apps_Monkey wrote:
    we're starting to get aquainted, but I think "best friend" could take a while as it is still as hard going as I recall, but I will persevere.Heh, it's not so bad! For example, if I had no idea how to test whether a file exists, I would just scan the big list of classes on the left for names that sound like they might include File operations. Hey look, File! Then I'd look at all of File's methods for something that tests whether it exists or not. Hey, exists! Then if I still couldn't figure out how to use it, I'd do a google search on that particular method.

  • Help with dynamic statement returning values into collection

    Hi All
    I am trying to use dynamic statement to return values into a collection using the returning clause. However, I get an ORA-00933 error. Here is a simple setup:
    create table t(
        pk number,
        id_batch varchar2(30),
        date_created date,
        constraint t_pk primary key ( pk )
    create or replace type num_ntt is table of number;
    create or replace type vc2_ntt is table of varchar2(30);
    create or replace
    package pkg
    as
      type rec is record(
          pk        num_ntt,    
          id_batch  vc2_ntt
      procedure p(
          p_count in number,
          p_rt    out nocopy rec
    end pkg;
    create or replace
    package body pkg
    as
      procedure p(
          p_count in number,
          p_rt    out nocopy rec
      is
      begin
          execute immediate '
          insert into t
          select level, ''x'' || level, sysdate
          from   dual
          connect by level <= :p_count
          returning pk, id_batch into :pk, :id_batch'
          using p_count returning bulk collect into p_rt.pk, p_rt.id_batch;
      end p;
    end pkg;
    declare
      r  pkg.rec;
    begin
      pkg.p( 5, r );
    end;
    /

    sanjeevchauhan wrote:
    but I am working with dynamic statement and returning multiple fields into a collection.And using an INSERT...SELECT statement combined with a RETURNING INTO clause still does not work. Whether it's dynamic SQL or not: it doesn't work. The link describes a workaround.
    By the way, I don't see why you are using dynamic SQL here. Static SQL will do just fine. And so you can literally copy Adrian's setup.
    Regards,
    Rob.

Maybe you are looking for

  • Need Help writing CLOB file

    I'm trying to write a servlet that receives a file upload and inserts the file into a CLOB in Oracle. Taking it one step at a time. I used the O'Reilly classes for file upload to receive the file and save it to disk. The next step of reading the file

  • HT1175 How do I backup to an older machine's sparsebundle?

    I have done a full restore to a new machine, which has worked...and I am told there should be an option to set to previous backups (to continue backing up to the same history). According to a Macworld article, when I connect to my Time Capsule for ba

  • Change Colors in Results Window

    Hi does anyone know how I can change the colors (text and backgrounf) of the results window?

  • How do I get my money back I am unable to download your program

    Since my iPad will not down load the program I am requesting my money back. I read about your program on an iPad I signed up on an iPad and you did not say one word about it. Now I feel scamed and I will not lay down.

  • Share your login manager screens/configs

    I haven't seen a login manager sharing thread yet on here. My contribution could be skipped as I have not done any customization yet, but posting a thread without picture at all would just feel wrong.. Have my SLiM: Last edited by daedalus.mythos (20