renigmaticx
Honorary Poster
- Joined
- Sep 11, 2016
- Posts
- 384
- Reaction
- 94
- Points
- 158
- Age
- 24
Hello po mga master patulong naman po ako sa codes ko, hindi ko po kasi matukoy kung pano ko makukuha yung return value nung methods na [1]FindHighest [2]FindLowest [3] FindMiddle na gagamitin ko sa method na ShowMenu. Baguhan lang ako at halos hindi ko alam pasikot sikot sa Java. Nahihirapan na ko kakaisip. Kaya sa mabait na master dyan patulong naman po ng techniques sa codes at error dito sa code. Thank you so much.
import java.io.*;
public class labhehe
{
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public static int GetInput() throws IOException
{
int num;
System.out.print("Enter a value: ");
num = Integer.parseInt(in.readLine());
return num;
}
public static boolean CheckValues(int num1, int num2, int num3) throws IOException
{
boolean checking = true;
if (num1 == num2 && num1 == num3)
{
System.out.println("All numbers are equal");
}
else if (num1 == num2 || num1 == num3)
{
System.out.println("Neither all are equal or different");
}
else
{
checking = false;
checking = ShowMenu();
}
return checking;
}
public static void ShowMenu(int num1, int num2, int num3, int category) throws IOException
{
int choice;
boolean checking;
if (checking == false)
{
System.out.print("Press [1] HIGHEST \nPress [2] MIDDLE \nPress [3] LOWEST \nPlease enter your choice: ");
choice = Integer.parseInt(in.readLine());
switch (choice)
{
case 1:
{
System.out.print("The highest value between " + num1 + ", " + num2 + ", " + num3 + ", is " + category);
break;
}
case 2:
{
System.out.print("The middle value between " + num1 + ", " + num2 + ", " + num3 + ", is " + category);
break;
}
case 3:
{
System.out.print("The lowest value between " + num1 + ", " + num2 + ", " + num3 + ", is " + category);
break;
}
default:
{
System.out.print("Invalid");
}
}
}
}
public static int FindHighest(int num1, int num2, int num3)
{
int category;
if (num1 > num2 && num1 > num3)
{
category = num1;
}
else if (num2 > num1 && num2 > 3)
{
category = num2;
}
else
{
category = num3;
}
return category;
}
public static int FindMiddle(int num1, int num2, int num3)
{
int category;
if (num1 < num2 && num1 < num3)
{
category = num1;
}
else if (num2 < num1 && num2 < 3)
{
category = num2;
}
else
{
category = num3;
}
return category;
}
public static int FindLowest(int num1, int num2, int num3)
{
int category;
if (num1 < num2 && num1 < num3)
{
category = num1;
}
else if (num2 < num1 && num2 < 3)
{
category = num2;
}
else
{
category = num3;
}
return category;
}
public static void main(String[] args) throws IOException
{
int num1, num2, num3, category = 0;
num1 = GetInput();
num2 = GetInput();
num3 = GetInput();
CheckValues(num1, num2, num3);
ShowMenu(num1, num2, num3, category);
}
}
import java.io.*;
public class labhehe
{
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public static int GetInput() throws IOException
{
int num;
System.out.print("Enter a value: ");
num = Integer.parseInt(in.readLine());
return num;
}
public static boolean CheckValues(int num1, int num2, int num3) throws IOException
{
boolean checking = true;
if (num1 == num2 && num1 == num3)
{
System.out.println("All numbers are equal");
}
else if (num1 == num2 || num1 == num3)
{
System.out.println("Neither all are equal or different");
}
else
{
checking = false;
checking = ShowMenu();
}
return checking;
}
public static void ShowMenu(int num1, int num2, int num3, int category) throws IOException
{
int choice;
boolean checking;
if (checking == false)
{
System.out.print("Press [1] HIGHEST \nPress [2] MIDDLE \nPress [3] LOWEST \nPlease enter your choice: ");
choice = Integer.parseInt(in.readLine());
switch (choice)
{
case 1:
{
System.out.print("The highest value between " + num1 + ", " + num2 + ", " + num3 + ", is " + category);
break;
}
case 2:
{
System.out.print("The middle value between " + num1 + ", " + num2 + ", " + num3 + ", is " + category);
break;
}
case 3:
{
System.out.print("The lowest value between " + num1 + ", " + num2 + ", " + num3 + ", is " + category);
break;
}
default:
{
System.out.print("Invalid");
}
}
}
}
public static int FindHighest(int num1, int num2, int num3)
{
int category;
if (num1 > num2 && num1 > num3)
{
category = num1;
}
else if (num2 > num1 && num2 > 3)
{
category = num2;
}
else
{
category = num3;
}
return category;
}
public static int FindMiddle(int num1, int num2, int num3)
{
int category;
if (num1 < num2 && num1 < num3)
{
category = num1;
}
else if (num2 < num1 && num2 < 3)
{
category = num2;
}
else
{
category = num3;
}
return category;
}
public static int FindLowest(int num1, int num2, int num3)
{
int category;
if (num1 < num2 && num1 < num3)
{
category = num1;
}
else if (num2 < num1 && num2 < 3)
{
category = num2;
}
else
{
category = num3;
}
return category;
}
public static void main(String[] args) throws IOException
{
int num1, num2, num3, category = 0;
num1 = GetInput();
num2 = GetInput();
num3 = GetInput();
CheckValues(num1, num2, num3);
ShowMenu(num1, num2, num3, category);
}
}