Employee and Java variables assignment
This commit is contained in:
Generated
+1
-1
@@ -8,7 +8,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="ms-25" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_26" default="true" project-jdk-name="openjdk-26" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,26 @@
|
||||
package ics3.other.EmployeeEarnings;
|
||||
|
||||
public class Employee {
|
||||
private String name;
|
||||
private double hourlyRate;
|
||||
private int hoursPerWeek;
|
||||
|
||||
public Employee(String name, double hourlyRate, int hoursPerWeek) {
|
||||
this.name = name;
|
||||
this.hourlyRate = hourlyRate;
|
||||
this.hoursPerWeek = hoursPerWeek;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public double getHourlyRate() {
|
||||
return this.hourlyRate;
|
||||
}
|
||||
|
||||
public int getHoursPerWeek() {
|
||||
return this.hoursPerWeek;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package ics3.other.EmployeeEarnings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class EmployeeEarnings {
|
||||
|
||||
public static void displayInfo() {
|
||||
System.out.printf("%70s %n %n", "MWPSB Employee Earnings");
|
||||
System.out.printf("%s %33s %33s %33s %n", "Employee", "Hourly Rate", "Hours per week", "Gross Monthly Salary");
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
displayInfo();
|
||||
ArrayList<Employee> employees = new ArrayList<>();
|
||||
|
||||
employees.add(new Employee("Akane Tsunemori", 31.50, 45));
|
||||
employees.add(new Employee("Shinya Kogami", 18.25, 24));
|
||||
employees.add(new Employee("Shusei Kagari", 22.00, 37));
|
||||
|
||||
for (int i = 0; i< employees.toArray().length; i++) {
|
||||
System.out.printf("%s %25.2f %27d %33.2f %n", employees.get(i).getName(), employees.get(i).getHourlyRate(), employees.get(i).getHoursPerWeek(), employees.get(i).getHourlyRate() * employees.get(i).getHoursPerWeek() * 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package ics3.other;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class JavaVariablesAssignement {
|
||||
public JavaVariablesAssignement(String firstName, String lastName) {
|
||||
this.printName(firstName, lastName);
|
||||
System.out.println();
|
||||
this.printNameByLetter(lastName);
|
||||
}
|
||||
|
||||
public void printName(String firstName, String lastName) {
|
||||
System.out.print(firstName.toLowerCase(Locale.ROOT) + " ");
|
||||
System.out.println(lastName.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public void printNameByLetter(String name) {
|
||||
for (int i = 0; i<name.length(); i++) {
|
||||
System.out.println(name.charAt(i));
|
||||
}
|
||||
}
|
||||
public static void displayTitle() {
|
||||
System.out.printf("Name program %n%n");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
displayTitle();
|
||||
JavaVariablesAssignement m = new JavaVariablesAssignement("Kuba", "Szatan");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user