Please support our Java advertiser: Lunarpages Java Web Hosting
![]() |
•
•
Join Date: May 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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
And need the Item part of the menu "df.format(curitemprice)" to update what the user enters. The user enters it in this method
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
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);
}Any ideas or pointers would help. Thanks
•
•
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation:
Rep Power: 9
Solved Threads: 18
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.
The itemCost method is the one that should be returning something, in my opinion.
•
•
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation:
Rep Power: 9
Solved Threads: 18
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.
The itemCost method is the one that should be returning something, in my opinion.
![]() |
Other Threads in the Java Forum
- Previous Thread: appending two java text files
- Next Thread: implementing a Stack using two Queues
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode