[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Missing post? - see this post about spam for more information.
!  XML
Forum Index » Java Programming
Author Message
jaykhjr

Newbie

Joined: 12/01/2011 16:47:57
Messages: 2
Offline

I have to write a small program in which I create a method entitles "MyMin". I must import a scanner, request the user to input 3 numbers, then I must create the method, call it, and use it to output the minimum of the three numbers with an "if else" statement. I have code but it is in shambles and Im going nuts. Its not for a grade, but when I can't get something in class it drives me nuts. help!
stdunbar

Newbie
[Avatar]

Joined: 06/22/2005 14:51:37
Messages: 884
Location: Superior, CO, USA
Online

I'm not sure what you're looking for - are you stuck on anything specifically?

Thanks for using the forums at hotjoe.com
[WWW] [Yahoo!] [ICQ]
jaykhjr

Newbie

Joined: 12/01/2011 16:47:57
Messages: 2
Offline

This is what I have, but I need some help finishing it. I dont know how to call the method and I know I have some syntax errors in here.


import java.util.Scanner;


public class MinOfThree
{
public static void main(String[] args)
{
Scanner readScanner = new Scanner(System.in);
double input1 = 0;
double input2 = 0;
double input3 = 0;

System.out.println("Please input a number");
myNumber = readScanner.nextInt();
System.out.println("Please input a second number");
myNumber2 = readScanner.nextInt();
System.out.println("Please input a third number");
myNumber3 = readScanner.nextInt();
}

public static double MainMin (double input1, double input2, double input3);
{
if (MainMin)
{
if ((input1 < input2) && (input1 < input3));
System.out.print("" + input1 + "is the minimum of the three digits");

else if ((input2 < input1) && (input2 < input3));
{
System.out.print("" + input2 + "Is the minimum of the three digits");
}

else if ((input3 < input1) && (input3 < input2));
{
System.out.print("" + input3 + "Is the minimum of the three digits");
}

}

}

}
chowbaaron

1 cup a day
[Avatar]

Joined: 11/06/2011 20:53:10
Messages: 47
Location: New York, USA
Offline

First of all, you need to indent your code. Not indenting makes it hard to read and find what you need.


To call the method, simply do this:



In your case, it would look like this (see line 20):

 
Forum Index » Java Programming
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2012 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle