Add chapters 9-17 for the java book
This commit is contained in:
10
Java-Kompendium/kap9/Coworker.java
Normal file
10
Java-Kompendium/kap9/Coworker.java
Normal file
@@ -0,0 +1,10 @@
|
||||
public class Coworker {
|
||||
public String firstName;
|
||||
public String lastName;
|
||||
public String number;
|
||||
public int salary;
|
||||
|
||||
public void increase(int percent) {
|
||||
this.salary += (salary / 100) * percent;
|
||||
}
|
||||
}
|
||||
29
Java-Kompendium/kap9/Task.java
Normal file
29
Java-Kompendium/kap9/Task.java
Normal file
@@ -0,0 +1,29 @@
|
||||
import java.io.*;
|
||||
|
||||
public class Task {
|
||||
public static void main(String[] arguments) {
|
||||
var coworker = new Coworker();
|
||||
|
||||
coworker.firstName = "Sebastian";
|
||||
coworker.lastName = "Mayer";
|
||||
coworker.number = "1234";
|
||||
coworker.salary = 3000;
|
||||
|
||||
System.out.print("Vorname: ");
|
||||
System.out.println(coworker.firstName);
|
||||
|
||||
System.out.print("Nachname: ");
|
||||
System.out.println(coworker.lastName);
|
||||
|
||||
System.out.print("Personalnummer: ");
|
||||
System.out.println(coworker.number);
|
||||
|
||||
System.out.print("Monatslohn: ");
|
||||
System.out.println(coworker.salary);
|
||||
|
||||
coworker.increase(5);
|
||||
|
||||
System.out.print("Monatslohn erhöht um 5%: ");
|
||||
System.out.println(coworker.salary);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user