-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab2.java
More file actions
35 lines (30 loc) · 1.27 KB
/
lab2.java
File metadata and controls
35 lines (30 loc) · 1.27 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Worker worker1 = new Worker();
worker1.name = "İlyas";
worker1.socialSecurityNumber = 551;
worker1.wage = 1000;
worker1.workingHours = 8;
displayInfo(worker1.name, worker1.socialSecurityNumber);
displaySalary((int) worker1.wage, worker1.workingHours);
Scanner scanner = new Scanner(System.in);
Worker worker2 = new Worker();
System.out.println("Write your name: ");
worker2.name = scanner.next();
System.out.println("Enter a Social Security Number: ");
worker2.socialSecurityNumber = scanner.nextInt();
System.out.println("Enter a Wage: ");
worker2.wage = scanner.nextInt();
System.out.println("Enter a Working Hours: ");
worker2.workingHours = scanner.nextInt();
displayInfo(worker2.name, worker2.socialSecurityNumber);
displaySalary((int) worker2.wage, worker2.workingHours);
}
public static void displayInfo(String name, int socialSecurityNumber) {
System.out.println(name + " " + socialSecurityNumber);
}
public static void displaySalary(int wage, int workingHours) {
System.out.println (wage * workingHours);
}
}