-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlec5.java
More file actions
36 lines (31 loc) · 1.09 KB
/
Copy pathlec5.java
File metadata and controls
36 lines (31 loc) · 1.09 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.*;
public class lec5 {
public static void printMyName(String name) {
System.out.println(name);
}
public static int calculateSum(int a, int b){
int sum = a + b;
return sum;
}
public static int calculateProduct(int c, int d){
int product = a * b;
return product;
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = sc.nextLine();
System.out.print("Your name is - ");
printMyName(name);
System.out.print("Enter first number: ");
int a = sc.nextInt();
System.out.print("Enter second number: ");
int b = sc.nextInt();
System.out.println("The sum of numbers is - " + calculateSum(a,b));
System.out.print("Enter first number for product: ");
int c = sc.nextInt();
System.out.print("Enter second number for product: ");
int d = sc.nextInt();
System.out.println("The product of numbers is - " + calculateProduct(c,d));
}
}