-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab 18 DoubleSum main and class.txt
61 lines (44 loc) · 1.15 KB
/
Lab 18 DoubleSum main and class.txt
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package Lab18;
package Lab18;
import java.util.Scanner;
public class Myclass
{
/*1. Write a method named DoubleSum()
to find the sum of squares of 2 numbers.
Two numbers should be entered by user,
and returns it to main (),
then print the value in main()
Ex. Input:2,3
Output: (2*2+3*3) =13
*/
public static void main(String [] args)
{
int sum;
lecture18 input= new lecture18();
sum=input.DoubleSum();
System.out.println(sum);
}
}
====================================================
lecture18
import java.util.Scanner;
public class lecture18
{/*1. Write a method named DoubleSum()
to find the sum of squares of 2 numbers.
Two numbers should be entered by user,
and returns it to main (),
then print the value in main()
Ex. Input:2,3
Output: (2*2+3*3) =13
*/
public static int DoubleSum( )
{
int sum=0;
Scanner input=new Scanner (System.in);
System.out.println("Please enter the 1st number:");
int num1=input.nextInt();
System.out.println("Please enter the 2nd number:");
int num2=input.nextInt();
sum= num1*num1+ num2*num2;
return sum;
}}