The whole question:
create a method with purpose
For every method you create, you need to write codes in the implementation class with an object calling the method and output the result. The following are specific:
Part 1: create a
` public method called switch_number()`
You can create it in your base class or derived class. (please follow)
` public void switch_number(int i, int j)`
----this is how you switch number
int t;
int w = 2;
int w2 = 4;
int t = w;
int w2 = t;
int w = w2;
this is syntax for switching numbers, I just don't know how to make a method out of this in a base class. Now Base class can't have public static void main(String[] args) {
{
}
Part 2: Create a
` public method called return_big()`
. This function will take 2 numbers and compare them, then return the bigger number back to caller
this is a if statement, I could give you guys the syntax for this, but i'm pretty sure most of you know how to do this
Part 3: Create a
`public method called sort_3()`
. This function will take 3 integers and use switch and compare to sort them out and print out 3 numbers from the smallest to the greatest.
this is also an if statement, I could give you guys syntax for this, but again i'm sure you guys know this
Also, I need to use joptionpane to get input and display output. Here is a sample of joption pane
import javax.swing.JOptionPane;
String z = JOptionPane.showInputDialog("Enter first integer:"); //asks user for input integer and stores it in string z
switch1= Integer.parseInt(z);//converts number in z and stores it in int w
String z2 = JOptionPane.showInputDialog("Enter second integer"); //asks user for second integer and stores it in z2
switch2 = Integer.parseInt(z2); //stores z2 number in int w2
This prompts user to enter integers. Please help me with the syntax for the basic class stuff, that is what I don't understand, and how to implement it into the implementation class just by calling on the object and method. Each parts can be done in the same base class, no need to make a new project for each part. Sorry if this is long, but I tried to be as specific as possible. Please help