1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Anyone here good with programming Java?

Discussion in 'BBS Hangout' started by TurtleBonzi, Apr 13, 2009.

  1. TurtleBonzi

    TurtleBonzi Member

    Joined:
    Dec 21, 2007
    Messages:
    516
    Likes Received:
    152
    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:
    [​IMG]

    So basically, I just need to have it say like 21,900 and not 21900.
     
  2. kaleidosky

    kaleidosky Your Tweety Bird dance just cost us a run

    Joined:
    Mar 20, 2002
    Messages:
    15,084
    Likes Received:
    1,352
  3. threedigithomy

    Joined:
    Jun 26, 2008
    Messages:
    52
    Likes Received:
    2

Share This Page

  • About ClutchFans

    Since 1996, ClutchFans has been loud and proud covering the Houston Rockets, helping set an industry standard for team fan sites. The forums have been a home for Houston sports fans as well as basketball fanatics around the globe.

  • Support ClutchFans!

    If you find that ClutchFans is a valuable resource for you, please consider becoming a Supporting Member. Supporting Members can upload photos and attachments directly to their posts, customize their user title and more. Gold Supporters see zero ads!


    Upgrade Now