RSS Forums RSS
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 679 | Replies: 3 | Solved | Thread Tools  Display Modes
Reply
Join Date: May 2006
Posts: 2
Reputation: monkeyphonics is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
monkeyphonics monkeyphonics is offline Offline
Newbie Poster

Help Help please

  #1  
May 2nd, 2006
Ok this is a homework program and this is my first JAVA course

I am stuck on how to pass double values from one method to another
I have a menu that appears with this code
 public static int menu(int curmenuselection, double curitemprice)
  {
   while(curmenuselection !=  5)
   {
   double subtotal = 0;
    double tax = 0;
    double total = 0;
    DecimalFormat df = new DecimalFormat("0.00");
    String entry;
     entry = JOptionPane.showInputDialog(null,
         "Item            " + df.format(curitemprice) + "\n" +
         "Subtotal     " + df.format(subtotal(finalprc)) + "\n" +
         "Tax             " + df.format(tax) + "\n" +
         "Total           " + df.format(total) + "\n" +
         "****************************************\n" +
         "1 - Enter Item Cost \n" +
         "2 - Clear Last Item \n" +
         "3 - Payment By Customer \n" +
         "4 - Close Out Customer \n" +
         "5 - Quit \n" +
         "Enter the number of your choice:", "Menu",
             JOptionPane.QUESTION_MESSAGE);
          curmenuselection = Integer.parseInt(entry);
          switch (curmenuselection)
          {
            case 1: itemcost(curitemprice);
              continue;
            case 2: dbg(curitemprice, finalprc);
              continue;
            case 3:
              continue;
            case 4:
              continue;
            case 5: System.exit(0);
              break;

          }
   }

And need the Item part of the menu "df.format(curitemprice)" to update what the user enters. The user enters it in this method

public static void itemcost(double curitemprice)
  {
    String entry;
             entry = JOptionPane.showInputDialog(null,
             "Enter Item Cost (Max of 4999.99)",
             "Item Cost",
             JOptionPane.QUESTION_MESSAGE);
       curitemprice = Double.parseDouble(entry);
  }
I am trying to pass the curitemprice to the method menu(int curmenuselection, double curitemprice) above but it will not display when the menu method refreshes.

Any ideas or pointers would help. Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: Help please

  #2  
May 2nd, 2006
Why does int menu return an int, but you aren't returning anything?
The itemCost method is the one that should be returning something, in my opinion.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: Help please

  #3  
May 2nd, 2006
Why does int menu return an int, but you aren't returning anything?
The itemCost method is the one that should be returning something, in my opinion.
Reply With Quote  
Join Date: May 2006
Posts: 2
Reputation: monkeyphonics is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
monkeyphonics monkeyphonics is offline Offline
Newbie Poster

Re: Help please

  #4  
May 2nd, 2006
Thanks anyway I figured it out
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the Java Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 1:32 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC