week 4 DONE SON
This commit is contained in:
parent
e9eaccab4d
commit
27dab22a7a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10
dropbox10/.classpath
Normal file
10
dropbox10/.classpath
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path=""/>
|
||||||
|
<classpathentry kind="output" path=""/>
|
||||||
|
</classpath>
|
||||||
17
dropbox10/.project
Normal file
17
dropbox10/.project
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>dropbox10</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
2
dropbox10/.settings/org.eclipse.core.resources.prefs
Normal file
2
dropbox10/.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
||||||
3
dropbox10/dropbox10/.gitignore
vendored
Normal file
3
dropbox10/dropbox10/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/Student.class
|
||||||
|
/StudentTest.class
|
||||||
|
/studenttest.class
|
||||||
58
dropbox10/dropbox10/Student.java
Normal file
58
dropbox10/dropbox10/Student.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
|
||||||
|
* Assignment 10
|
||||||
|
|
||||||
|
* Course: CISS238
|
||||||
|
|
||||||
|
* Student: Scott Steely
|
||||||
|
|
||||||
|
* Date: Sep 19, 2025
|
||||||
|
|
||||||
|
*/
|
||||||
|
package dropbox10;
|
||||||
|
public class Student {
|
||||||
|
// fields
|
||||||
|
private String name;
|
||||||
|
private int score;
|
||||||
|
private static int bonus;
|
||||||
|
private static int numberOfStudents;
|
||||||
|
// accessors
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public int getScore() {
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
public int getBonus() {
|
||||||
|
return bonus;
|
||||||
|
}
|
||||||
|
public int getNumberOfStudents() {
|
||||||
|
return numberOfStudents;
|
||||||
|
}
|
||||||
|
// mutators
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
public void setScore(int score) {
|
||||||
|
this.score = score;
|
||||||
|
}
|
||||||
|
public void setBonus(int bonus) {
|
||||||
|
Student.bonus = bonus;
|
||||||
|
}
|
||||||
|
// constructor
|
||||||
|
public Student(String name, int score) {
|
||||||
|
this.name = name;
|
||||||
|
this.score = score;
|
||||||
|
numberOfStudents++;
|
||||||
|
}
|
||||||
|
// toString
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String str;
|
||||||
|
str = String.format("Name: %s%nScore: %d%nCurved score: %d%n"
|
||||||
|
+ "Total student: %d%n",
|
||||||
|
getName(), getScore(), getScore()+getBonus(),
|
||||||
|
getNumberOfStudents());
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
51
dropbox10/dropbox10/StudentTest.java
Normal file
51
dropbox10/dropbox10/StudentTest.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
|
||||||
|
* Assignment 10
|
||||||
|
|
||||||
|
* Course: CISS238
|
||||||
|
|
||||||
|
* Student: Scott Steely
|
||||||
|
|
||||||
|
* Date: Sep 19, 2025
|
||||||
|
|
||||||
|
*/
|
||||||
|
package dropbox10;
|
||||||
|
import java.util.Scanner;
|
||||||
|
public class StudentTest {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
// variables
|
||||||
|
int numberofstudents = 0;
|
||||||
|
String name;
|
||||||
|
int score;
|
||||||
|
int bonus;
|
||||||
|
// prompt user for number of students
|
||||||
|
System.out.println("enter number of students: ");
|
||||||
|
numberofstudents = input.nextInt();
|
||||||
|
// create an array
|
||||||
|
Student[] students = new Student[numberofstudents];
|
||||||
|
// use a loop for student data
|
||||||
|
for(int i = 0 ; i < students.length; i++) {
|
||||||
|
// remove the enter key when the user enters the number above
|
||||||
|
input.nextLine();
|
||||||
|
System.out.println("enter student " + (i+1) + "'s name: ");
|
||||||
|
name = input.nextLine();
|
||||||
|
System.out.println("enter student " + (i+1) + "'s score: ");
|
||||||
|
score = input.nextInt();
|
||||||
|
// create the student
|
||||||
|
Student s = new Student(name, score);
|
||||||
|
// add the student to the array
|
||||||
|
students[i] =s;
|
||||||
|
}
|
||||||
|
// prompt for bonus if any
|
||||||
|
System.out.println("enter bonus: ");
|
||||||
|
bonus = input.nextInt();
|
||||||
|
// set bonus for just one student
|
||||||
|
students[0].setBonus(bonus);
|
||||||
|
// display by using a shorthand for loop
|
||||||
|
for(Student s: students) {
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
10
dropbox11/.classpath
Normal file
10
dropbox11/.classpath
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path=""/>
|
||||||
|
<classpathentry kind="output" path=""/>
|
||||||
|
</classpath>
|
||||||
17
dropbox11/.project
Normal file
17
dropbox11/.project
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>dropbox11</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
2
dropbox11/.settings/org.eclipse.core.resources.prefs
Normal file
2
dropbox11/.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
||||||
2
dropbox11/dropbox11/.gitignore
vendored
Normal file
2
dropbox11/dropbox11/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/Employee.class
|
||||||
|
/Employee_Test.class
|
||||||
73
dropbox11/dropbox11/Employee.java
Normal file
73
dropbox11/dropbox11/Employee.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
|
||||||
|
* Assignment 11
|
||||||
|
|
||||||
|
* Course: CISS238
|
||||||
|
|
||||||
|
* Student: Scott Steely
|
||||||
|
|
||||||
|
* Date: Sep 19, 2025
|
||||||
|
|
||||||
|
*/
|
||||||
|
package dropbox11;
|
||||||
|
public class Employee{
|
||||||
|
// fields
|
||||||
|
private String name;
|
||||||
|
private int hours_worked;
|
||||||
|
private float pay_rate;
|
||||||
|
private static float overtime_mult;
|
||||||
|
private static int numberOfEmployees;
|
||||||
|
// accessors
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public int getHours_Worked() {
|
||||||
|
return hours_worked;
|
||||||
|
}
|
||||||
|
public float getPay_Rate() {
|
||||||
|
return pay_rate;
|
||||||
|
}
|
||||||
|
public float getOvertime_Mult() {
|
||||||
|
return overtime_mult;
|
||||||
|
}
|
||||||
|
// mutators
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
public void setHours_Worked(int hours_worked) {
|
||||||
|
this.hours_worked = hours_worked;
|
||||||
|
}
|
||||||
|
public void setPay_Rate(float pay_rate) {
|
||||||
|
this.pay_rate = pay_rate;
|
||||||
|
}
|
||||||
|
public void setOvertime_Mult(float overtime_mult) {
|
||||||
|
Employee.overtime_mult = overtime_mult;
|
||||||
|
}
|
||||||
|
// constructor
|
||||||
|
public Employee(String name, int hours_worked, float pay_rate, float overtime_mult) {
|
||||||
|
this.name = name;
|
||||||
|
this.hours_worked = hours_worked;
|
||||||
|
Employee.overtime_mult = overtime_mult;
|
||||||
|
this.pay_rate = pay_rate;
|
||||||
|
numberOfEmployees++;
|
||||||
|
}
|
||||||
|
// method
|
||||||
|
public float getTake_Home_Pay() {
|
||||||
|
float Take_Home_Pay = (float) 0.00;
|
||||||
|
if (getHours_Worked() < 40) {
|
||||||
|
Take_Home_Pay = (getPay_Rate() * getHours_Worked());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Take_Home_Pay = (getPay_Rate() * 40) + ( (getHours_Worked() - 40 ) * (getPay_Rate() * getOvertime_Mult()));
|
||||||
|
}
|
||||||
|
return Take_Home_Pay;
|
||||||
|
}
|
||||||
|
|
||||||
|
// toString
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String str;
|
||||||
|
str = String.format("Name: %s%nTake home pay:%s%n", getName(), getTake_Home_Pay());
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
51
dropbox11/dropbox11/Employee_Test.java
Normal file
51
dropbox11/dropbox11/Employee_Test.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
|
||||||
|
* Assignment 11
|
||||||
|
|
||||||
|
* Course: CISS238
|
||||||
|
|
||||||
|
* Student: Scott Steely
|
||||||
|
|
||||||
|
* Date: Sep 19, 2025
|
||||||
|
|
||||||
|
*/
|
||||||
|
package dropbox11;
|
||||||
|
import java.util.Scanner;
|
||||||
|
// public class EmployeeTest
|
||||||
|
public class Employee_Test {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
// variables
|
||||||
|
String name;
|
||||||
|
int hours_worked;
|
||||||
|
float pay_rate;
|
||||||
|
float overtime_mult;
|
||||||
|
int numberOfEmployees;
|
||||||
|
// prompt for ot bonus
|
||||||
|
System.out.println("enter all employee pay overtime multiplier: ");
|
||||||
|
overtime_mult = input.nextFloat();
|
||||||
|
System.out.println("enter total employees ");
|
||||||
|
numberOfEmployees = input.nextInt();
|
||||||
|
// create an array
|
||||||
|
Employee[] employee = new Employee[numberOfEmployees];
|
||||||
|
// loop to fill the array
|
||||||
|
for(int i = 0 ; i < employee.length; i++) {
|
||||||
|
// remove the enter key when the user enters the number above
|
||||||
|
input.nextLine();
|
||||||
|
System.out.println("enter employee name: ");
|
||||||
|
name = input.nextLine();
|
||||||
|
System.out.println("enter hours worked: ");
|
||||||
|
hours_worked = input.nextInt();
|
||||||
|
System.out.println("enter pay rate: ");
|
||||||
|
pay_rate = input.nextInt();
|
||||||
|
// create the employee
|
||||||
|
Employee s = new Employee(name, hours_worked, pay_rate, overtime_mult);
|
||||||
|
// add employee to the array
|
||||||
|
employee[i] =s;
|
||||||
|
}
|
||||||
|
for(Employee s: employee) {
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user