Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Method not printing...

  1. #1
    Junior Member
    Join Date
    May 2017
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Method not printing...

    Hey guys,

    I've been working on this for a few days. My method, displayHSP isn't printing out. The code is running without errors, but it is just running and saying "Process finished with exit code 0," and no of the System.out.println(...); that should be printing is printing. Can you take a look for me. This literally my third day on this stuff, so I'm probably missing something obvious. My IDE is saying there are no errors, but, again, it's not doing the print out. Code below:

    public class Main {
     
        public static void main(String[] args) {
    	// write your code here
        }
     
                 int hsp = calcHSP(1500);{
                displayHSP("Steve", hsp);
     
                hsp = calcHSP(900);
                displayHSP("Bob", hsp);
     
                hsp = calcHSP(400);
                displayHSP("Joey", hsp);
     
                hsp = calcHSP(50);
                displayHSP("Jimmy", hsp);
                 }
     
        public static void displayHSP(String playerName, int hsp) {
            System.out.println(playerName + "managed to get into position"
                    + hsp + "on the high score table");
        }
     
        public static int calcHSP(int playerScore) {
            if (playerScore > 1000) {
                return 1;
            } else if (playerScore > 500 && playerScore < 1000) {
                return 2;
            } else if (playerScore > 100 && playerScore < 500) {
                return 3;
            } else {
                return 4;
            }
        }
     
     
    }
    Last edited by Jlepp82; May 31st, 2017 at 10:44 AM.

  2. #2
    Member
    Join Date
    May 2017
    Location
    Eastern Florida
    Posts
    68
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Method not printing...

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    Be sure the {s are on lines by themselves and not hidden on lines with other statements
    Last edited by NormR; May 31st, 2017 at 09:55 AM.

  3. #3
    Junior Member
    Join Date
    May 2017
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Method not printing...

    A friend of mine who has been coding for years fixed in like 30 seconds. I had closed off the main method without any code in it. Lesson learned, I guess!

Similar Threads

  1. [SOLVED] Why is Java not printing my method results?
    By cheshire in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 13th, 2014, 08:04 PM
  2. Printing from a Method
    By LoganC in forum What's Wrong With My Code?
    Replies: 11
    Last Post: October 4th, 2012, 06:33 PM
  3. Printing data from a method
    By LoganC in forum What's Wrong With My Code?
    Replies: 10
    Last Post: September 23rd, 2012, 06:51 AM
  4. Calling a print method from another class (printing array)
    By Kaldanis in forum Object Oriented Programming
    Replies: 7
    Last Post: November 25th, 2011, 12:32 PM
  5. Error in printing method as always it prints the last value
    By TommyFiz in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 1st, 2009, 10:37 AM

Tags for this Thread