Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by unclejuicy ( 7 years ago )
package project4;
import java.util.Scanner;
public class Project4
{
public static int myMax(int num1, int num2)
{
if (num1 > num2)
{
return num1;
}
return num2;
}
public static int myMin(int num1, int num2)
{
if (num1 < num2)
{
return num1;
}
return num2;
}
public static boolean isSquare(int num1, int num2)
{
if ((num1 * num1) == num2)
{
return true;
}
return false;
}
public static void main(String[] args)
{
int num1;
int num2;
Scanner input = new Scanner(System.in);
System.out.print("Please enter a positive non-zero integer: ");
num1 = input.nextInt();
System.out.print("Please enter a positive non-zero integer: ");
num2 = input.nextInt();
if ((num1 <= 0) || (num2 <= 0))
{
System.out.println("Error: Both numbers must be positive and "
+ "non-zero");
}
else
{
System.out.println("\nThe maximum of the two numbers is "
+ myMax(num1,num2) + ".");
System.out.println("The minimum of the two numbers is "
+ myMin(num1,num2) + ".");
if (isSquare(myMin(num1, num2), myMax(num1, num2)) == true)
{
System.out.println("The number "
+ myMax(num1, num2) + " is the square of "
+ myMin(num1,num2) + ".");
}
else
System.out.println("The number "
+ myMax(num1, num2) + " is not the square of "
+ myMin(num1, num2) + ".");
}
}
}
Revise this Paste