Need help returning an Int!!!

here is the code for my sport quiz class:
import javax.swing.*;
public class Sport
     public static int main (String []args)
Object[] sportValues = { "Freddie", "jimbo", "the destroyer" };
Object sportq1;
Object[] sportValues2 = { "David Beckham", "Alessandro Del Piero",
"Michael Ballack" };
Object sportq2;
Object[] sportValues3 = { "6", "10", "14" };
Object sportq3;
int sportScore = 0;
String message;
//............QUESTION 1..............
sportq1 = JOptionPane.showInputDialog(null, "Question 1: What nickname is given to england cricketer andrew flintoff?", "selection", JOptionPane.YES_NO_CANCEL_OPTION, null,
sportValues, sportValues[0]);
if (sportq1.equals(sportValues[0]))
message = "CORRECT!";
JOptionPane.showMessageDialog(null, message);
sportScore = (sportScore+1);
     else
     message = "WRONG!";
     JOptionPane.showMessageDialog(null, message);
     //............QUESTION 2.............
sportq2 = JOptionPane.showInputDialog(null, "Question 2: Who scored italy's second goal in the world cup final?", "selection", JOptionPane.YES_NO_CANCEL_OPTION, null,
sportValues2, sportValues2[0]);
if (sportq2.equals(sportValues2[1]))
message = "CORRECT!";
JOptionPane.showMessageDialog(null, message);
sportScore = (sportScore+1);
     else
     message = "WRONG!";
     JOptionPane.showMessageDialog(null, message);
     //............QUESTION 3.............
sportq3 = JOptionPane.showInputDialog(null, "Question 3: how many players are there in an ice hockey team?", "selection", JOptionPane.YES_NO_CANCEL_OPTION, null,
sportValues3, sportValues3[0]);
if (sportq3.equals(sportValues3[0]))
message = "CORRECT!";
JOptionPane.showMessageDialog(null, message);
sportScore = (sportScore+1);
     else
     message = "WRONG!";
     JOptionPane.showMessageDialog(null, message);
     return sportScore;
i am trying to return the 'sportScore' int to a main quiz class but for some reason it hasnt worked...
can anyone tell me what i have done wrong?
thanks alot!

this is my main quiz class:
import javax.swing.*;
public class Quiz
     public static void main (String []args)
         Object[] possibleValues = { "Sport", "Music", "General Knowledge", "TV and Film", "Display Score Board" };
         Object choice;
         do
      choice = JOptionPane.showInputDialog(null,"Welcome to my quiz\nPlease select you category:", "selection", JOptionPane.YES_NO_CANCEL_OPTION, null,
      possibleValues, possibleValues[0]);
      if  (choice.equals(JOptionPane.CANCEL_OPTION))
    System.exit(0);
    if (choice.equals(possibleValues[0]))
        Sport.doQuiz();
     if (choice.equals(possibleValues[1]))
        Music.doQuiz();
     if (choice.equals(possibleValues[2]))
        General.doQuiz();
    if (choice.equals(possibleValues[3]))
        TV.doQuiz();
    if (choice.equals(possibleValues[4]))
        int sportScore = Sport.doQuiz();
        int tvScore = TV.doQuiz();
        int musicScore = Music.doQuiz();
        int generalScore = General.doQuiz();
        int totalScore = (sportScore+tvScore+musicScore+generalScore);
        JOptionPane.showMessageDialog(null,"Thankyou for taking my quiz!\nhere are your results:\nSport: "
        + sportScore + "/3\nMusic: " + musicScore + "/3\nGeneral Knowledge: "
        + generalScore + "/3\nTV and Film: " + tvScore +"/3\n\nTOTAL: "
        + totalScore + "/12!");
    while(!(choice.equals(possibleValues[4])));
    }as you can see i have more than just the sport category but once i know how to do that one i will be able to do the rest...
now here is my sport class:
import javax.swing.*;
public class Sport
       public static int doQuiz()
          Object[] sportValues = { "Freddie", "jimbo", "the destroyer" };
            Object sportq1;
          Object[] sportValues2 = { "David Beckham", "Alessandro Del Piero",
"Michael Ballack" };
            Object sportq2;
          Object[] sportValues3 = { "6", "10", "14" };
            Object sportq3;
            int sportScore = 0;
            String message;
     //............QUESTION 1..............
            sportq1 = JOptionPane.showInputDialog(null, "Question 1: What nickname is given to england cricketer andrew flintoff?", "selection", JOptionPane.YES_NO_CANCEL_OPTION, null,
            sportValues, sportValues[0]);
            if (sportq1.equals(sportValues[0]))
              message = "CORRECT!";
        JOptionPane.showMessageDialog(null, message);
        sportScore = (sportScore+1);
         else
             message = "WRONG!";
          JOptionPane.showMessageDialog(null, message);
         //............QUESTION 2.............
            sportq2 = JOptionPane.showInputDialog(null, "Question 2: Who scored italy's second goal in the world cup final?", "selection", JOptionPane.YES_NO_CANCEL_OPTION, null,
            sportValues2, sportValues2[0]);
            if (sportq2.equals(sportValues2[1]))
              message = "CORRECT!";
        JOptionPane.showMessageDialog(null, message);
          sportScore = (sportScore+1);
         else
         message = "WRONG!";
         JOptionPane.showMessageDialog(null, message);
         //............QUESTION 3.............
            sportq3 = JOptionPane.showInputDialog(null, "Question 3: how many players are there in an ice hockey team?", "selection", JOptionPane.YES_NO_CANCEL_OPTION, null,
            sportValues3, sportValues3[0]);
            if (sportq3.equals(sportValues3[0]))
              message = "CORRECT!";
        JOptionPane.showMessageDialog(null, message);
          sportScore = (sportScore+1);
         else
             message = "WRONG!";
          JOptionPane.showMessageDialog(null, message);
         return sportScore;
}i am tring to return sportScore from the sport class to the main quiz class, at the moment instead of getting the sportScore at the end of the quiz class it is now running the whole sport class again!
what have i done wrong?
ta

Similar Messages

  • Need help returning correct name from a code created movie clip

    Hello. I am an AS3 n00b with hopefuly a simple question I am designing a simple game in flash. This code creates an array of movie clips and asigns a picture to each one. It is a map screen. What I need is when I click on one of the created movie clips, I need it to return either the index of the clip in the array or the name of the clip. Basicaly anything I can use to tell them apart in the code. Here is the code:
    import flash.display.MovieClip;
    var MapLoader:Array = new Array();
    var strJPGext:String = ".jpg";
    var intContTileNumber:int;
    var strContTilePath:String;
    var intDistStartX:int = 63;
    var intDistStartY:int = 64;
    var intDistMultiplyY:int = 0;
    var intDistMultiplyX:int = 0;
    var intDistCount:int = 0;
    var MapSquare:Array = new Array();
    for (var i:int = 0; i < 729; i++)
             //var MapSquare:MovieClip = new MovieClip();
            MapSquare.push (new MovieClip());
            MapSquare[i].x = intDistStartX + (intDistMultiplyX * 30);
            MapSquare[i].y = intDistStartY + (intDistMultiplyY * 30);
            MapSquare[i].name = "MapSquare" + i ;
            addChild(MapSquare[i]);
            intContTileNumber = i;
            MapLoader.push (new Loader);
            strContTilePath = intContTileNumber + strJPGext;
            MapLoader[i].load(new URLRequest(strContTilePath));
            MapSquare[i].addChild(MapLoader[i]);
            intDistCount++;
            intDistMultiplyX++;
            if (intDistCount > 26){
            intDistCount = 0;
            intDistMultiplyX = 0;
            intDistMultiplyY++;
    stage.addEventListener(MouseEvent.CLICK, reportClick);
    function reportClick(event:MouseEvent):void
        trace("movieClip Instance Name = " + event.target.name);   
    Now all this works fine, it creates the map and assigns the correct picture and places them in the correct X,Y position and it is the correct grid of 27x27 squares. The problem is with the name, when I click on the movie clip, it returns "Instance2" or "Instance5" or whatever. It starts with 2 and then increases each number by 3 for each clip, so the first one is 2, then 5 then 8 and so on. This is no good. I need it to return the name that I assigned it
    . If I put the code in trace(MapSquare[1]) it will return the name "MapSquare1" so I know the name was assigned, but it isnt returning.
    Please assist
    Thanks,
    -red

    Thanks for the resopnse,
    I know I dont really need the name, I just need the index number of the array, but I cant figure out how to get the index name without specificaly coding for it. That is why in the listener event I use event.target.name because I dont know what movie clip is being clicked until it has been clicked on. Basically when a movie clip is clicked it needs to return which index of the array was clicked.
    I could do it this way:
    MapSquare[0].addEventListener(
      MouseEvent.MOUSE_UP,
      function(evt:MouseEvent):void {
        trace("I've been clicked!");
    MapSquare[1].addEventListener(
       MouseEvent.MOUSE_UP,
       function(evt:MouseEvent):void {
         trace("I've been clicked!");
    MapSquare[2].addEventListener(
       MouseEvent.MOUSE_UP,
       function(evt:MouseEvent):void {
         trace("I've been clicked!");
    ... ect
    but that is unreasonable and it kind of defeats the purpose of having the array in the first place. The code that each movie clip executes is the same, eventualy that index will be passed into a database and the data at that primary key will be retrieved and returned to the program. So I just need to know, when one of those buttons is clicked, which one was clicked and what is its index in the array.
    I am a VB programer and in VB this is very easy, the control array automatically sends its own index into the function when one of the buttons is clicked. It seems simple enough, I just dont know how to do it in action script.
    Thanks again,
    -red

  • Need help returning (not printing) avg GPA from array??

    Here's what I have so far. After returning the value then I gotta print the avg in a separate method. I also need to check the names of the first and last student using an "equals" method. Please someone help with whatever you can. Here's what I got:
    import java.util.Scanner;
    public class StudentLists {
    //Main method. Prompts user for the number of students.
       public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       System.out.print("Please enter the number of students in this class: ");
       int s = in.nextInt();
       Student[] students=new Student[s];
       FillStudents(s,students);
       printAll(students);
       public static void FillStudents(int s, Student[] students){
       for (int i=0; i<s; i++)
            Scanner inf = new Scanner(System.in);
            System.out.println("Please enter student's first name: ");
        String first = inf.nextLine();
        System.out.println("Please enter student's last name: ");
            String last=inf.nextLine();
            System.out.println("Please enter the number of credits completed: ");
            int c=inf.nextInt();
            System.out.println("Please enter student's GPA: ");
            Double g=inf.nextDouble();
            students[i] = new Student(first, last, c, g);
        public static void printAll(Student[] students) {
        System.out.println("Names      Credits  GPA");
           for(int i = 0; i < students.length; i++)
        System.out.println(students);
    public static Double getAvg(Student[] students, Double g){
    double sum=0.0;
    double avg=0.0;
    for(int i=0; i<students.length; i++){
    sum+=g;
    avg=sum/students.length;
    return avg;

    Oh no I wasn't giving any orders. I was saying I have been trying to edit what I have, but I can't figure out how to get the method right to do my average of the GPA from the loop. I don't know what to put in there. I was just asking if you would write it and then kind of explain what u did for me please.
    import java.util.Scanner;
    public class StudentLists {
    //Main method. Prompts user for the number of students.
       public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       System.out.print("Please enter the number of students in this class: ");
       int s = in.nextInt();
       Student[] students=new Student[s];
       FillStudents(s,students);
       printAll(students);
       public static void FillStudents(int s, Student[] students){
       for (int i=0; i<s; i++)
            Scanner inf = new Scanner(System.in);
            System.out.println("Please enter student's first name: ");
        String first = inf.nextLine();
        System.out.println("Please enter student's last name: ");
            String last=inf.nextLine();
            System.out.println("Please enter the number of credits completed: ");
            int c=inf.nextInt();
            System.out.println("Please enter student's GPA: ");
            Double g=inf.nextDouble();
            students[i] = new Student(first, last, c, g);
        public static void printAll(Student[] students) {
        System.out.println("Names      Credits  GPA");
           for(int i = 0; i < students.length; i++)
        System.out.println(students);
    public static Double getAvg(Student[] students){
    double sum=0.0;
    double avg=0.0;
    for(int i=0; i<students.length; i++){
    avg=sum/students.length;
    System.out.println(avg);
    return avg;

  • Need help returning processor task list.

    I'm new to KEXT/Kernel programming and Xcode, so I'm sure these are fairly beginner questions, but I'm having some trouble.  I'm trying to return a list of processor tasks, so I can test different things such as process id's, file descriptors, etc.
    I'm not sure what functions would be useful for me.  Is there some way that I would be able to return a list of all running processor tasks and/or their information?  Would someone be able to point me in the right direction?

    Yeah, usually it helps me out quite a bit, but I've been googling for over a week, and I get a whole lot of nothing.  Everything that I've actually been able to find uses outdated headers and functions that don't exist anymore.  Maybe my google skills just aren't very good for this area, since I *am* new to this after all...
    I figured it would be much more time-efficient to just ask the dev community.  Any insight would be appreciated.

  • Need help returning largest of three numbers....

    Hello,
    I'm stuck in an essential part of a program. The objective of the program is suppose to call a static method that will find and return the largest of three numbers. Im suppose to test the program with the following three sets of three numbers: (2, 5, 8), (2, 10, 5), (67, 23, 17).
    After lots of thinking, I decided to write a program that will do exactly what the objective requires, but without calling a static method that will find and return. I tried calling a static method but it's real confusing and I couldnt do it right.
    Below is my program, the top part is right I think, but calling a static method and returning the value is the part Im having trouble in.
    // The "LargeNum3" class.
    import java.awt.*;
    import hsa.Console;
    public class LargeNum3
        static Console c;           // The output console
        public static void main (String [] args)
            c = new Console ();
            int num [] = new int [3];
            int largest;
            largest = num [0];
            for (int i = 0 ; i < 3 ; i++)
                c.println ("Please enter in 3 values");
                for (int a = 0 ; a < 3 ; a++)
                    num [a] = c.readInt ();
                for (int b = 0 ; b < num.length ; b++)
                    if (num > largest)
    largest = num [b];
    c.println ();
    c.println ("The largest number is " + largest);
    c.println ();
    } // LargeNum3 class

    // The "LargeNum3" class.
    import java.awt.*;
    import hsa.Console;
    public class LargeNum3
        static Console c;           // The output console
        // Declare a new static method to return the
        // largest number in the array passed to it
        public static int findLargest(int[] nums)
            int j, largest=nums[0];
            for (j=1; j<nums.length; j++)
                if (nums[j]>largest) largest=nums[j];
            return largest;
        public static void main (String [] args)
            c = new Console ();
            int num [] = new int [3];
            // int largest;
            // largest = num [0]; It was wrong to put this here in
            // in the first place
            for (int i = 0 ; i < 3 ; i++)
                c.println ("Please enter in 3 values");
                for (int a = 0 ; a < 3 ; a++)
                    num [a] = c.readInt ();
                c.println ();
                c.println ("The largest number is " + findLargest(num));
                c.println ();
    } // LargeNum3 class

  • Need help returning only 1min

    I'm working on a custom Discrete Job Picklist and am trying to return the locator with the least amount of the item that is required to pick. This is working fine except when the minimum is not distinct.
    Here's the bit of code that I'm working with:
    and d.total_qoh = (select min(f.total_qoh)
    from apps.mtl_onhand_locator_v f
    where d.item = f.item)
    This returns the mins but give me duplicates when the mins are the same. I'd like to return only 1 min locator per item. I've tried using a select distinct, but this does not work.
    Ideally, I'd like to use the min(locator_id) to determine which locator to use should the min(total_qoh) be non-distinct.
    I've tried using:
    and d.total_qoh = (select *(select min(f.total_qoh)
    from apps.mtl_onhand_locator_v f
    where d.item = f.item
    order by d.locator_id)
    where rownum = 1)
    But I don't think that order by is allowed in 8.1.6.1 and so it is not working. Likewise, I can't seem to get TOP N to work.
    Any suggestions?
    -Tracy
    Here's the full sql:
    select b.wip_entity_name "Job #",
           d.padded_concatenated_segments "Item",
           d.item_description "Description",
           c.REQUIRED_QUANTITY "Qty",
           e.segment1 "Row",e.segment2 "Section", e.segment3 "Shelf", e.segment4 "Bin",
           d.total_qoh "Qty at Loc",
           d.locator_id
    from wip.wip_discrete_jobs a, wip.wip_entities b, wip.wip_requirement_operations c, apps.mtl_onhand_locator_v d,  inv.mtl_item_locations e
    where a.wip_entity_id = b.wip_entity_id
    and   a.wip_entity_id = c.wip_entity_id
    and   c.inventory_item_id =  d.inventory_item_id
    and   d.locator_id = e.inventory_location_id
    and   d.ORGANIZATION_ID = '5'
    and   b.wip_entity_name >= '70319'--:job_low
    and   b.wip_entity_name <= '70320'--:job_high
    and   e.segment1 is not null
    and   a.status_type in  ('3', '1') --released and unreleased jobs
    and   d.total_qoh = (select min(f.total_qoh)
                        from apps.mtl_onhand_locator_v f
                        where d.padded_concatenated_segments = f.padded_concatenated_segments)
    order by b.wip_entity_name, e.segment1, e.segment2, e.segment3, e.segment4; Thanks for any help you can offer.
    -Tracy

    Richard - this is yielding ora-00904: invalid column. Although I have verified that the column names are correct. I think this may have something to do with not allowing an order by in a subquery for 8.1.6.1 but am not positive. It seems that I either get an invalid column name or missing right parenthesis when using order by in the subquery.
    and d.locator_id = (select locator_id
                           from (select locator_id
                                    from apps.mtl_onhand_locator_v
                                    where d.padded_concatenated_segments = f.padded_concatenated_segments
                                    order by total_qoh desc, locator_id desc)
                           where rownum = 1)
    -Tracy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need help returning to default application icons

    ok, i began to change the icons on my iBook tonight and then decided i wanted the original ones back, when to my dismay i realized i didnt know where to look.
    Where are they?

    irishexpatriate, they are still there. "Get Info" (command-i) on the file you want to change back, then choose the small icon window and delete.
    -mj
    [email protected]

  • Need help on returning input

    Hi. I'm making a DateTimePicker (DTP), and I need help on getting a method to return a Date only when the DTP is closed, and I want this to be done in the DTP class itself.
    For now, I've used an infinite loop and it seems to work fine without lagging the computer (my computer is above average), but I'm not sure if there's another more efficient way.
    I would prefer not to use threads, but if that's the only option then I suppose it's unavoidable.
    I'm using:
    while(true){
        switch(returnState){
        case UNINITIALIZED: continue;
        case SET: return cal.getTime();
        case CANCELED:
            default:
            return null;
    }Screenshots:
    http://i34.tinypic.com/53rb7n.png
    http://i33.tinypic.com/2nsxct4.png
    Azriel~

    You could put any component in a JOptionPane or a JDialog and then easily query the component for results once it has returned.
    For example:
    QueryComponent.java creates a component that can be placed in a JOptionPane and then queried.
    import java.awt.GridLayout;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JComponent;
    import javax.swing.JTextField;
    * A simple component that has two JTextFields and two
    * corresponding "getter" methods to extract information
    * out of the JTextFields.
    * @author Pete
    public class QueryComponent
      private JPanel mainPanel = new JPanel();
      private JTextField firstNameField = new JTextField(8);
      private JTextField lastNameField = new JTextField(8);
      public QueryComponent()
        mainPanel.setLayout(new GridLayout(2, 2, 5, 5));
        mainPanel.add(new JLabel("First Name: "));
        mainPanel.add(firstNameField);
        mainPanel.add(new JLabel("Last Name: "));
        mainPanel.add(lastNameField);
      public String getFirstName()
        return firstNameField.getText();
      public String getLastName()
        return lastNameField.getText();
      // get the mainPanel to place into a JOptionPane
      public JComponent getComponent()
        return mainPanel;
    }QueryComponentTest.java places the component above into a JOptionPane, shows the pane, and then queries the QueryComponent object for the results.
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JComponent;
    public class QueryComponentTest
      private JPanel mainPanel = new JPanel();
      public QueryComponentTest()
        JButton getNamesBtn = new JButton("Get Names");
        getNamesBtn.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            getNamesAction();
        mainPanel.add(getNamesBtn);
      // occurs when button is pressed
      private void getNamesAction()
        // create object to place into JOptionPane
        QueryComponent queryComp = new QueryComponent();
        // show JOptionPane
        int result = JOptionPane.showConfirmDialog(mainPanel,
            queryComp.getComponent(), // place the component into the JOptionPane
            "Get Names",
            JOptionPane.INFORMATION_MESSAGE);
        if (result == JOptionPane.OK_OPTION) // if ok selected
          // query the queryComp for its contents by calling its getters
          System.out.println("First Name: " + queryComp.getFirstName());
          System.out.println("Last Name:  " + queryComp.getLastName());
      public JComponent getComponent()
        return mainPanel;
      private static void createAndShowUI()
        JFrame frame = new JFrame("QueryComponentTest");
        frame.getContentPane().add(new QueryComponentTest().getComponent());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args)
        java.awt.EventQueue.invokeLater(new Runnable()
          public void run()
            createAndShowUI();
    }Edited by: Encephalopathic on Sep 29, 2008 8:16 PM

  • My iphone 6 turned off while i was using face time and it returns with the screen saying Hello mean its reset automatically how is this possible ? Now it requires an id and password to activate which i do not remember need help ?

    My iphone 6 turned off while i was using face time and it returns with the screen saying Hello mean its reset automatically how is this possible ? Now it requires an id and password to activate which i do not remember need help ? but i do remember the id and password which i was using on itunes and Apple store. please i almoost buy it in 890$ so it will be a big lost please help me.

    shahzadfromlahore wrote:
    Now it requires an id and password to activate which i do not remember need help ? but i do remember the id and password which i was using on itunes and Apple store. please i almoost buy it in 890$ so it will be a big lost please help me
    Who set up the phone? Who's Apple ID was used to activate it?

  • I NEED HELP!! Been calling since the end of Nov and being charged for a Warranty device. The device was returned the next day!! Been calling twice a week.. NEED RESOLUTION

    I NEED HELP!! Been calling since the end of Nov and being charged for a Warranty device. The device was returned the next day!! Been calling twice a week.. I NEED HELP 6 TCC TICKETS HAVE BEEN OPENED - PROMISED CALLS BACK AND NEVER GET CALLS.
    About to cancel my account and move to AT&T
    TCC TICKETS:  (removed)
    I am trying here for the last resort. After this evening my account along with my business account will be cancelled. Total lines that Verizon will have lost will be 93 lines.
    PLEASE SOMEONE JUST HELP ME!!!!
    I already tweeted and facebook messaged Verizon. Your CS group has gone down hill over the last 3-6 months. I use to enjoy being a customer.
    >> Edited to comply with the Verizon Wireless Terms of Service <<

    not all the lines have ETF's. I have 30 tablets and the rest phones. The phones have ETFs and the tablets are all month to month.
    The total to move my account over is going to come out to about $8500.
    Rep has been trying to get my business for years.  I was always loyal to Verizon until this happened.

  • Need to return data from a query in different ways - Please help

    We are using 10g R2
    I have a proc as follows that has a query with over 100 values in the select clause:
    proc one( input param1, input_param2,.... output_cursor )
    as
    begin
    open cursor for
    select ...about 100 values with most of them being calculated
    from table1, view 1, table2, table 3, view 2 ...
    where ....
    and table1.col1 = input param1
    and table1.col2 = input param 2
    and view1.col5 = input param5...
    end;
    I need to return the data that comes from the above query in different formats, columns for a report would be different from columns for screen A and different for screen B. I need only certain columns for a report and different set of columns for another screen. I have wrapper procs that get different input params. From the wrapper procs I intend to call the above proc but would like only selected values.
    How can I accomplish this? Since my main goal is to select different columns for each wrapper I was thinking of insert the data from the above proc into global temp table and selecting whatever columns and order I want from the wrappers.
    What do you think? Any other solutions?
    Thanks
    Edited by: user565033 on Jan 21, 2013 7:50 PM

    You need to clearly separate roles and responsibilities. The PL/SQL code that creates and supplies a cursor handle is server code tasked to supply data. The code that makes the call for server data, is responsible for formatting and rendering that data.
    Thus moving data formatting into the server code needs to be question. Simple example. Cursor does not return invoice date as a date - but formats it into a string using TO_CHAR().
    This works for client1 - as that is the date format expected. However, client2 has different International settings and specifies a different date format. Invoice date, formatted into a string by the server, now renders in the wrong format on client2.
    Server code should not be concerned with rendering and formatting of data send to a client.
    As for the idea to use a global temp table is ..., well to put it nicely, it smells. Badly.
    The single most expensive operation on a database platform is I/O. And now you want to read server data and write it to temporary storage, and the read data from temporary storage to return to the client? What on earth for!? Why purposefully increase the size of the I/O workload? Why decrease performance and undermine scalability?
    Provide a proper abstraction interface to the client. Enable it to specify (as simplistically as possible) what it wants ito data. There are a number of ways to design and implement this in PL/SQL. Simplistic example:
    SQL> create or replace package Employees as
      2 
      3          EMP_FULL_DETAILS        constant integer := 1;
      4          EMP_BASIC_DETAILS       constant integer := 2;
      5 
      6          procedure GetEmpByID(
      7                  cur out sys_refcursor,
      8                  empID in emp.empno%type,
      9                  template in integer default EMP_BASIC_DETAILS
    10          );
    11 
    12          procedure GetEmpByName(
    13                  cur out sys_refcursor,
    14                  empName in emp.ename%type,
    15                  template in integer default EMP_BASIC_DETAILS
    16          );
    17  end;
    18  /
    Package created.
    SQL>
    SQL> create or replace package body Employees as
      2 
      3  type TArray is table of varchar2(32767);
      4 
      5  TemplateList       constant TArray :=
      6          new TArray(
      7                  'EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO ',
      8                  'EMPNO, ENAME, JOB '
      9          );
    10 
    11  procedure GetEmpByID(
    12          cur out sys_refcursor,
    13          empID in emp.empno%type,
    14          template in integer default EMP_BASIC_DETAILS
    15  ) is
    16          sqlSelect       varchar2(32767);
    17  begin
    18          sqlSelect :=
    19                  'select '||TemplateList(template)||
    20                  'from emp where empno = :empID';
    21 
    22          open cur for sqlSelect using empID;
    23  end;
    24 
    25  procedure GetEmpByName(
    26          cur out sys_refcursor,
    27          empName in emp.ename%type,
    28          template in integer default EMP_BASIC_DETAILS
    29  ) is
    30          sqlSelect       varchar2(32767);
    31  begin
    32          sqlSelect :=
    33                  'select '||TemplateList(template)||
    34                  'from emp where ename like :empName';
    35          open cur for sqlSelect using empName;
    36  end;
    37 
    38 
    39  end;
    40  /
    Package body created.
    SQL>
    SQL> var c refcursor
    SQL>
    SQL> exec Employees.GetEmpByID( :c, 7499 );
    PL/SQL procedure successfully completed.
    SQL> print c
         EMPNO ENAME      JOB
          7499 ALLEN      SALESMAN
    SQL>
    SQL> exec Employees.GetEmpByName( :c, 'A%', Employees.EMP_FULL_DETAILS );
    PL/SQL procedure successfully completed.
    SQL> print c
         EMPNO ENAME      JOB               MGR HIREDATE                   SAL       COMM     DEPTNO
          7499 ALLEN      SALESMAN         7698 1981/02/20 00:00:00       1600        300         30
          7876 ADAMS      CLERK            7788 1987/05/23 00:00:00       1100                    20
    SQL>

  • Need help pl/sql function body returning SQL query - Reports

    I need help with Grouping by on a report that I developed in my application.
    I have posted my Code in
    Apex.oracle.com
    workspace : c a s e _ m a n a g e m e n t
    User Id : public
    Password : public
    I need help on Page 38 Reports.
    I get blank lines when I do break by first , second and third columns on the reports attribute.
    So I think I have to write "group by " or Distinct in side the SQL query. But not sure how to do it there.
    Thank you

    Is this an APEX question, then try here:
    Oracle Application Express (APEX)
    Is this an Oracle Reports question, then try here:
    Reports
    Is this an SQL question:
    Please provide sample data and expected output. Also please show what you have tried already.

  • Warranty return process needs help!

    I purchased the extended warranty for my Ipad.  Until the most recent process change we have had great service from the Crossgates Mall location in Albany, NY.  However, last week we needed to return the ipad for service because of a cracked screen that prevented ANY use.  After driving 1/2 hour to the store over the weekend we were told the service process has changed and we now need to start a ticket number to have a prepaid box mailed to us for the return.  We have received the box and upon trying to schedule a UPS pickup I am told pickup is not covered by BB.  I have two small children and a service dog so getting out is very difficult!  My only choice is to wait until the weekend when I can get out again.  The needed service has now been delayed by over a week SO FAR not to mention transit time back to BB, time to repair, and transit time back to us.  I'm guessing this will be a total of 4 weeks.  My 6 year old has assignments on the Ipad and as you can imagine there aren't "loaners" from school. The "work-arounds" are a pain in the rear! I interpret this process change as a deliberate attempt to discourage use of the extended warranty.  I am extremely frustrated!

    Hello frogbates,
    The Geek Squad Protection plans are always a great way to protect your devices should something unexpectedly go wrong, especially if you have young children that will be using them! I’m glad to hear you were able to turn to this plan when your iPad’s screen cracked, making it unusable.
    With devices being serviced via Geek Squad Service Fulfillment, our customers have multi-channel options for service fulfillment under their plans. These options include a self-service option so that a trip to the store is not required, beginning their service fulfillment request over the phone, or in-store.
    While the self-service option is encouraged, we should not be denying assistance to our customers who still prefer the in-store option. Our agents should still be able to assist in beginning your service fulfillment request, and I am truly sorry if this was not the experience you had at the Crossgates Mall location in Albany, NY.
    I’m glad to hear that you were able to get your service fulfillment request started, and have received the box. That being said, this shipment would need to be dropped off at a UPS location as UPS pickup is not included. I understand that this may not be the most ideal situation for you, and apologize for any inconvenience this may cause. I would encourage you to drop your package off at a UPS location as soon as possible to continue with the service fulfillment process. 
    If you should have any questions in regards to this fulfillment, please let me know!
    Regards, 
    Tasha|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Need help to draw a graph from the output I get with my program please

    Hi all,
    I please need help with this program, I need to display the amount of money over the years (which the user has to enter via the textfields supplied)
    on a graph, I'm not sure what to do further with my program, but I have created a test with a System.out.println() method just to see if I get the correct output and it looks fine.
    My question is, how do I get the input that was entered by the user (the initial deposit amount as well as the number of years) and using these to draw up the graph? (I used a button for the user to click after he/she has entered both the deposit and year values to draw the graph but I don't know how to get this to work?)
    Please help me.
    The output that I got looked liked this: (just for a test!) - basically this kind of output must be shown on the graph...
    The initial deposit made was: 200.0
    After year: 1        Amount is:  210.00
    After year: 2        Amount is:  220.50
    After year: 3        Amount is:  231.53
    After year: 4        Amount is:  243.10
    After year: 5        Amount is:  255.26
    After year: 6        Amount is:  268.02
    After year: 7        Amount is:  281.42
    After year: 8        Amount is:  295.49
    After year: 9        Amount is:  310.27
    After year: 10        Amount is:  325.78
    After year: 11        Amount is:  342.07
    After year: 12        Amount is:  359.17
    After year: 13        Amount is:  377.13
    After year: 14        Amount is:  395.99
    After year: 15        Amount is:  415.79
    After year: 16        Amount is:  436.57
    After year: 17        Amount is:  458.40And here is my code that Iv'e done so far:
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.lang.Math;
    import java.text.DecimalFormat;
    public class CompoundInterestProgram extends JFrame implements ActionListener {
        JLabel amountLabel = new JLabel("Please enter the initial deposit amount:");
        JTextField amountText = new JTextField(5);
        JLabel yearsLabel = new JLabel("Please enter the numbers of years:");
        JTextField yearstext = new JTextField(5);
        JButton drawButton = new JButton("Draw Graph");
        public CompoundInterestProgram() {
            super("Compound Interest Program");
            setSize(500, 500);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            amountText.addActionListener(this);
            yearstext.addActionListener(this);
            JPanel panel = new JPanel();
            panel.setBackground(Color.white);
            panel.add(amountLabel);
            amountLabel.setToolTipText("Range of deposit must be 20 - 200!");
            panel.add(amountText);
            panel.add(yearsLabel);
            yearsLabel.setToolTipText("Range of years must be 1 - 25!");
            panel.add(yearstext);
            panel.add(drawButton);
            add(panel);
            setVisible(true);
            public static void main(String[] args) {
                 DecimalFormat dec2 = new DecimalFormat( "0.00" );
                CompoundInterestProgram cip1 = new CompoundInterestProgram();
                JFrame f = new JFrame();
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.getContentPane().add(new GraphPanel());
                f.setSize(500, 500);
                f.setLocation(200,200);
                f.setVisible(true);
                Account a = new Account(200);
                System.out.println("The initial deposit made was: " + a.getBalance() + "\n");
                for (int year = 1; year <= 17; year++) {
                      System.out.println("After year: " + year + "   \t" + "Amount is:  " + dec2.format(a.getBalance() + a.calcInterest(year)));
              @Override
              public void actionPerformed(ActionEvent arg0) {
                   // TODO Auto-generated method stub
    class Account {
        double balance = 0;
        double interest = 0.05;
        public Account() {
             balance = 0;
             interest = 0.05;
        public Account(int deposit) {
             balance = deposit;
             interest = 0.05;
        public double calcInterest(int year) {
               return  balance * Math.pow((1 + interest), year) - balance;
        public double getBalance() {
              return balance;
    class GraphPanel extends JPanel {
        public GraphPanel() {
        public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setColor(Color.red);
    }Your help would be much appreciated.
    Thanks in advance.

    watertownjordan wrote:
    http://www.jgraph.com/jgraph.html
    The above is also good.Sorry but you need to look a bit more closely at URLs that you cite. What the OP wants is a chart (as in X against Y) not a graph (as in links and nodes) . 'jgraph' deals with links and nodes.
    The best free charting library that I know of is JFreeChart from www.jfree.org.

  • Help, I am killing myself trying to do this and I need help ASAP

    I need help with this program it has to act like a cash register. The user will input an items price and then their payment. It will tell you the change and then tell you what kinda of change to use, see example below:
    Use JOptionPane to take inputs from the user and display the results.
    Example:
    If the user enters
    Amount Due = 5.52 // First Input from the User
    Amount Given = 10.00 // Second Input from the User
    Calculate the Balance Due
    Balance Amount = $ 4.48
    and display the balance due in denomination as (The following four lines will be ONE Output to the user)
    $1 bill = 4 (4.00)
    Quarters = 1 (0.25)
    Dimes = 2 (0.20)
    Pennies = 3 (0.03)
    This last part, where you display the change that will be given back, ie: how many quarters, dimes, nickels, pennies is the part I am having problems with.
    Can some one help? Please pardon my coding abilities, I am still learning how to do this and would really appreciate any help you can with my program.
    Thanks in advance.
    import javax.swing.*;
    import java.text.*;
    public class CashReg
    { //Start
    public static void main (String [] args)
    { //Start Main
    int count = 0;
    char c1 = 0;
    String price = null;
    String payment = null;
    String change = null;
    boolean correct = false;
    while(!correct)
    { //Start Loop
    price = JOptionPane.showInputDialog (null,"Enter the amount of the item for purchase");
    if (price.length() < 1) //Loop
    JOptionPane.showMessageDialog (null, "You did not enter a purchase amount, try again please.");//Error message
    payment = JOptionPane.showInputDialog (null,"Enter your payment amount.");
    if (payment.length() < 1) //Loop
    JOptionPane.showMessageDialog (null, "You did not enter a payment amount, try again please.");//Error message
    else
    correct = true; //Boolean to confirm that there are enough characters
    for (int i=0; i<price.length(); i++)
    if (Character.isUpperCase(price.charAt(i)))
    count++;
    } //End loop
    // response = price - payment;
    JOptionPane.showMessageDialog (null, "You item costs "+price+" and you payed "+payment+" and your change will be "+change);
    System.exit(0);
    } //End Main
    } //End

    OK, thanks for your help, but I need some more. I have the program running and showing the amount of change that is going to be returned. But I don't know how to display the kind of change. AKA, quarters, dimes, nickels and pennies. I am a programming idot, my teacher is letting us twist in the wind. He is not explaining the concepts behind any of this. You are saying the word "logic" and I don't know what that means. This assigment is due Monday, I just need some help with the last part. How to show the change. I am just plain lost. please help.
    import java.text.DecimalFormat;
    import javax.swing.*;
    import java.text.*;
    public class CashReg
    {     //Start
         public static void main (String [] args)
         {          //Start Main
              int count = 0;
              char c1 = 0;
              String price = null;
              String payment = null;
              String change = null;
              boolean correct = false;
         while(!correct)
         {          //Start Loop
         price = JOptionPane.showInputDialog (null,"Enter the amount of the item for purchase");
              if (price.length() < 1)     //Loop
                   JOptionPane.showMessageDialog (null, "You did not enter a purchase amount, try again please.");//Error message
                   payment = JOptionPane.showInputDialog (null,"Enter your payment amount.");
              if (payment.length() < 1)     //Loop
                   JOptionPane.showMessageDialog (null, "You did not enter a payment amount, try again please.");//Error message
              else
                   correct = true; //Boolean to confirm that there are enough characters
    for (int i=0; i<price.length(); i++)
              if (Character.isUpperCase(price.charAt(i)))
              count++;
         }     //End loop
    //     response = price - payment;
    float fPrice = Float.parseFloat(price);
    float fPayment = Float.parseFloat(payment);
    float fChange = fPayment-fPrice;
    DecimalFormat df = new DecimalFormat ("#.00");
    JOptionPane.showMessageDialog (null, "You item costs "+price+" and you payed "+payment+" and your change will be "+ df.format (fChange));
    This is where I don't know what to put
         System.exit(0);
         }     //End Main
         }     //End
    I am begging for help.

Maybe you are looking for

  • Wireless driver not working on hp 4540s after system move

    Hi there, I have moved my arch linux system from HP probook 4520s to  model 4540s and since then I cannot get wifi working by any reasonable means no metter  what I modprobe it wifi is alwais down: my lsmod: Module Size Used by xfs 666515 0 exportfs

  • Hyperlink in forms

    I want to create a HyperLink Button in our Forms application that opens an IE Browser for another application which resides on a different Server. I will also pass a data string to the other application. After the work is done on this application, Th

  • File merge using BPM

    Hi, I am trying to merge few files using BPM . I have tried for splitting the files . Can any one guide me how to proceed with the correlation and Receiver Determinations.

  • Need MDF 1.3

    My CW installation is running Common Services 3.3.0 with MDF 1.25. Going via the GUI in CW to update Common Services (either Software Update or Device Update) from cisco.com returns the message that I am running the latest version. Yet when I downloa

  • Error connecting to MDM over Portal

    Hi! I have some difficulities with connecting to MDM repository over Portal. I have a working Java project, which connects to the repositroy and executes a search without error. I developed a WD type DC where I want to use the previous Java program.