| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 12/01/2011 16:51:53
|
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!
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 12/02/2011 10:59:46
|
stdunbar
Newbie
![[Avatar]](/images/avatar/a87ff679a2f3e71d9181a67b7542122c.png)
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 |
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 12/02/2011 11:12:28
|
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");
}
}
}
}
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 01/06/2012 19:05:38
|
chowbaaron
1 cup a day
![[Avatar]](/images/avatar/905056c1ac1dad141560467e0a99e1cf.png)
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):
|
|
|
 |
|
|