• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Complete noob question I apologize for my sheer and utter stupidy up front.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);


 
Ranch Hand
Posts: 317
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

totalItems = totalItems++;



Change it to just or

Search the forums, there have been questions on why it doesnt work.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

We have a FAQ entry about this: Post Increment Operator And Assignment
 
Wendell Hatcher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried what people recommended? Did you read the FAQ they pointed you to? If you did, tell us what happened once you changed your code as they suggested, and what (if any) problem you still have.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic