-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathSimpleMethod3.java
More file actions
36 lines (30 loc) · 1.15 KB
/
SimpleMethod3.java
File metadata and controls
36 lines (30 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Scanner;
public class SimpleMethod3 {
/*
NOTE: You can create multiple methods with the same name and different return
types or parameters (Overloading methods).
Overloaded methods can even call each-other, but you'll have to type
the arguments correctly and cast upon return.
*/
public static int square(int number) {
// Put your code here
return 0;
}
public static double square(double number) {
// Put your code here
return 0;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("What number would you like to square: ");
/* Integers Used */
int input = Integer.valueOf(scanner.nextLine());
int result = square(input);
System.out.printf("The square of %d is %d%n", input, result);
System.out.print("What number would you like to square: ");
/* Doubles used */
double input2 = Double.valueOf(scanner.nextLine());
double result2 = square(input2);
System.out.printf("The square of %f is %f%n", input2, result2);
}
}