I want to make this program below but I'm not sure how i would start them. Would i use methods with or without return? I have this due tomorrow and cannot figure it out. I've wrote the code multiple times but ended up deleteing it all.

    Part 1:
    Allow user to enter one character (L or S) and three integers between 100 and 1000.
    The program should output the following:
    1.  Display the message: “Wrong input!” if the numbers are not included in the interval [100-1000] using method CheckInput;
    2.  The largest number if the user enters the letter L, using method Largest;
    3.  The smallest number if the user enters the letter S, using method Smallest;
    4.  All numbers and their digits reversed using the method Backwards;
    5.  Using the method EvenOrOdd that takes one integer and outputs ‘True’ if the number is even or ‘False’ if it is odd, output the numbers entered followed by ‘True’ or ‘False’
    6.  Use the method CheckDivisor, that takes all three numbers and checks if the first number is a divisor of the second or third, and returns ‘True’ or ‘False’
    7.  Make the output easier to understand and add two more methods to the program

    Part 2: 
    Write a program that allows the user to enter 3 words
    1.  Using the method Alphabetical output the three words in alphabetical order
    2.  In the main program concatenate(join) the three words, in alphabetical order in one variable ALL and using the method Mix replace all vowels by x
    3.  Call method First2Last2 to show the first and last 2 characters of the variable ALL, only if ALL has more than 4 characters, otherwise output the message “Invalid command!” 
    4.  Call method Middlexx to insert xx right in the middle of the word ALL if the number of characters in ALL is even; otherwise replace the middle letter by yy

This is what a method with return looks like:

class method2{
 int perimeter(int L, int W){
int peri=2*(L+W);
return peri;
public static void main(String str[]){
method2 m = new method2();
System.out.print(10+""+5+"" + m.perimeter(10,5));

Without return:

class method1{
void perimeter(int L, int W){

int peri=2*(L+W);
public static void main(String str[]){
method1 m = new method1();
  • $\begingroup$ Coding questions and questions about writing code are off-topic for this site; see our help center. $\endgroup$
    – D.W.
    Commented Nov 30, 2015 at 6:40

1 Answer 1


You only need to use a return if you plan to return a value or object to the caller. So for instance if you called a method, that then performed a calculation such as an addition you could return the result of that calculation. If you do not need to return anything to the caller then you do not need to use a return.


Not the answer you're looking for? Browse other questions tagged or ask your own question.