P
PseudoKiller
Guest
I need to...
Write a Java program with the following methods:
Named ‘first’ that will input a number and return it.
Named ‘second’ that will input a number and return it.
Named ‘small’ that will find the smaller of the two numbers and return it.
This is what I have so far...
Write a Java program with the following methods:
Named ‘first’ that will input a number and return it.
Named ‘second’ that will input a number and return it.
Named ‘small’ that will find the smaller of the two numbers and return it.
This is what I have so far...
Code:
[font=Courier New][color=#941edf]
import[/color][/font][font=Courier New] cs1.Keyboard; //this is used for Keyboard inputs
[/font][font=Courier New][color=#941edf]public [/color][/font][font=Courier New][color=#941edf]class[/color][/font][font=Courier New] BigSmall
{
[/font][font=Courier New][color=#941edf]public [/color][/font][font=Courier New][color=#941edf]static [/color][/font][font=Courier New][color=#941edf]void[/color][/font][font=Courier New] main (String[] args)
{[/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] num1, num2;
System.out.println ([/font][font=Courier New][color=#00cb00]"Enter the first number "[/color][/font][font=Courier New]);
num1 = Keyboard.readInt();
System.out.println ([/font][font=Courier New][color=#00cb00]"Enter the second number "[/color][/font][font=Courier New]);
num2 = Keyboard.readInt();
[/font][font=Courier New][color=#941edf]static [/color][/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] first ([/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] num1)
{[/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] a;
a = num1;
[/font][font=Courier New][color=#941edf]return[/color][/font][font=Courier New] a;
}
[/font][font=Courier New][color=#941edf]static [/color][/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] second ([/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] num2)
{[/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] b;
b = num2;
[/font][font=Courier New][color=#941edf]return[/color][/font][font=Courier New] b;
}
[/font][font=Courier New][color=#941edf]static [/color][/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] smaller ([/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] a, [/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New] b)
{
[/font][font=Courier New][color=#941edf]if[/color][/font][font=Courier New] a < b;
[/font][font=Courier New][color=#941edf]return[/color][/font][font=Courier New] a;
}
}
}
[/font]