Currently I'm in a beginner's course for programming Java and so far it's going well. However I can't seem to figure out this tiny problem in one of my programs. Code: import static java.lang.System.*; import java.util.*; import java.awt.*; public class Java1409 { public static void main(String[] args) { Stairs climb = new Stairs(); climb.input(); climb.process(); climb.output(); } } class Stairs { int numStairs; int numTripsPerDay; int numYears; int totalPerDay; int totalPerYear; int grandTotal; void input() { Scanner scan = new Scanner(in); out.println("How many stairs are on your staircase?"); numStairs = scan.nextInt(); out.println("How many trips a day do you make up and down the steps?"); numTripsPerDay = scan.nextInt(); out.println("How many years have you lived in your house?"); numYears = scan.nextInt(); } void process() { totalPerDay = numStairs * 2 * numTripsPerDay; totalPerYear = totalPerDay * 365; grandTotal = totalPerYear * numYears; } void output() { out.println(); out.println("Stairs climbed per day: " + totalPerDay ); out.println("Stairs climbed per year: " + totalPerYear ); out.println("Stairs climbed in your lifetime: " + grandTotal ); out.println(); } } That's the code I'm using and it works just fine. But my teacher won't give me credit for it unless I let the final input have commas in it. My current output: So basically, I just need to have it say like 21,900 and not 21900.
google is your friend (seriously, if you're gonna be a programmer in any way...you'll want to learn how to google for problems you come across) http://www.java2s.com/Tutorial/Java...lagtodisplaynumberswiththousandsseparator.htm
use decimal format, here is an example http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html