This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to get set values from do while loop into next function? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

How to get set values from do while loop into next function?

Wendell Hatcher
Greenhorn

Joined: Aug 01, 2011
Posts: 3
My question is about the increment I am asking how do you return data from the do while loop that is suppose to be set in each value.

the totalSales inside of my do while loop should have data set when it comes out of the loop it does not save the data into the totalSales or totalItems values.

// The system print out values are empty.
System.out.printf(salesID + " you entered a total of: " + totalItems + "With a total sales of $%15.2f" + totalSales);

I am trying to return data from a freaky do while or the if statement loop and it will not return the items I set why?


// yesno to n for first loop through.

do {
System.out.println("Welcome Sales ID: " + salesID + " please enter the samsung TV sold: \n");
samsungProduct = scanValue.next();
System.out.println("Please enter your total TV sales amounts individually for today \n");
singleSale = scanValue.nextDouble();
totalSales = totalSales + singleSale;
totalItems = totalItems++;
System.out.println("Do you want to enter another sales total(Y/N): \n ");
yesNo = scanValue.next();

} while (!yesNo.equalsIgnoreCase("N"));

// get the items set inside of the do while loop.

// The system print out values are empty.
System.out.printf(salesID + " you entered a total of: " + totalItems + "With a total sales of $%15.2f" + totalSales);
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16


that line is wrong. you should just do

You may want to read this FAQ.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

sigh...now that I've wasted my time answering this question, I find you've already asked it.

Closing this thread.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to get set values from do while loop into next function?
 
Similar Threads
endless loop
TreeMap question#1
Complete noob question I apologize for my sheer and utter stupidy up front.
ArrayList selection Sort
StackOverflowError