CECS277 Project 1 to 11 solutions

$180.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Project1 CECS277

Write a program to Calculate the federal tax, state tax and the net salary for each employee.
First, ask how many employees there are in that company.
To calculate the federal tax, use the following criteria:
To calculate the state Tax, use the following criteria:
If the employee is from CA, NV, AZ, or TX calculate the state tax at 10%
Otherwise calculate the state tax at 12%
Your program should Calculate the display the net salary of each employee. To
calculate the net salary, subtract federal and state tax from the gross salary.
Then, ask for the name, salary, marital status, and the state employee lives in .

Project2 CECS277

Student average score
Professor Navarro is trying to find the average score for 5 exams. She wants to drop the lowest
and highest scores from the list before finding the average.
Below is a sample input list of students with 5 scores for 5 exams:
studentName ex1 ex2 ex3 ex4 ex5
===================================
Jones Tom 94 99 96 74 56
Thompson Frank 67 58 86 95 47
Jackson Tom 95 97 94 87 67
Jackie Michael 43 23 34 77 64
Johnson Sara 84 93 64 57 89
Colt McCoy 84 93 64 57 70
Freeman Tina 67 58 86 95 47
• First, we will ask the user to enter the number of students in her class. Then, we will ask
student name and scores for 5 exams. Store this information into a two-dimensional array.
Your program should include the following methods:
• getStudentInfo() should ask the user for student info including student name and 5 scores,
before storing each of these scores into the array, make sure to validate it by calling another
method ValidateUserInput(score). The method getStudentInfo() should be called from the
main method.
• findLowest(scores) should find and return the lowest of the 5 scores passed to it.
• findHighest(scores) should find and return the highest of the 5 scores passed to it.
• calcScore(scores) should calculate and return the average of the 3 scores that
remain after dropping the highest and lowest scores the student received. This
method should be called just once by main and should be passed the scores.
findHighest() and findLowest(), should be called by calcScore, which uses the returned
information to determine which of the scores to drop.
• print() method will display the table in the following format.
Sample output:
student Name ex1| ex2| ex3| ex4| ex5|Average
==========================================
Jones Tom 94 99 96 74 56 88
Thompson Frank 67 58 86 95 47 70.33
Jackson Tom 95 97 94 87 67 ..
Jackie Michael 43 23 34 77 64 ..
Johnson Sara 84 95 64 57 89 ..
Colt McCoy 84 93 86 67 70 80
Freeman Tina 67 58 86 95 47

Project3 CECS277

Description: Write a program that will read the information of students from scores.txt file. Your program should calculate student’s average test scores and their letter grades. Use ArrayLists for this project. One ArrayList to store the student’s names. The other ArrayList would store the test scores, and an ArrayList to store the letter grades. Your program should contain the following functions. • readData() Method to reads and stores the data into two ArrayLists. • calculateAverage() Method to calculate the average test scores and grades. static double calculateAverage(ArrayList scores) • findLowestScore() Finds the lowest score and returns it to the calculateAverage(). static double findLowestScore(ArrayList scores) • writeData() Method to write the result into a file result.txt. This Method should write student name, average, and letter grade into the file. • classAverage() This method will find the class average and returns it. Class Average will be stored as the last line in the result.txt file. • Use the following Criteria for letter grades. If Average is 98-100… Assign the grade “A+” If Average is 95-97… Assign the grade “A” If Average is 91-94… Assign the grade “A-” If Average is 88-90… Assign the grade “B+” If Average is 84-87… Assign the grade “B” If Average is 80-83… Assign the grade “B-” If Average is 75-79… Assign the grade “C+” If Average is 70-74… Assign the grade “C” If Average is less than 70 and greater than 60 assign grade “D” If Average is less than or equal 60 assign grade “NC”

Project4 CECS277

Inventory Class
Design an Inventory class that can hold information for an item in a retail store’s inventory.
The class should have the following private member variables.
Variable Name Description
itemNumber An int that holds the item’s number.
quantity An int that holds the quantity of the item on hand.
cost A double that holds the wholesale per-unit cost of the item
Member Methods Description
default constructor Sets all the member variables to 0.
constructor #2 Accepts an item’s number, quantity, and cost as arguments.
Calls other class methods to copy these values into the appropriate member
variables.
setItemNumber Accepts an int argument and copies it into the itemNumber member variable.
setQuantity Accepts an int argument and copies it into the quantity member variable.
setCost Accepts a double argument and copies it into the cost member variable.
getItemNumber Returns the value in itemNumber.
getQuantity Returns the value in quantity.
getCost Returns the value in cost.
getTotalCost Computes and returns the totalCost.
Boolean ValidInt(int) validates for integer values entered by the user not to be negative. Call this
method from setItemNumber, and setQuantity. Program should loop if negative values entered.
Boolean ValidFloat(double) validates for cost entered by the user not to be negative. Call this
method from setCost. Program should loop if negative values entered.
Demonstrate the class by writing a simple client program that uses it. This program should user
inputs and validate the user inputs to ensure that negative values are not accepted for item
number, quantity, or cost.
I executed the jar file generated on the command line the way it was
described during lecture.
java -jar project4.jar
Please see the sample output.

Project5 CECS277

Employee and ProductionWorker Classes
Design a class named Employee. The class should keep the following
information in fields:
▪ Employee name
▪ Employee number in the format XXX–L, where each X is a digit
within the range 0–9, and the L is a letter within the range A–M. It
should be total of 5 characters.
isValidEmpNum:
This private method returns true if the argument e is a
valid Employee ID number. Othewise, it returns false. The
isValidEmpNum should be called from setEmployeeNumber().
As long as the user does not enter a valid Employee number
in the right format, isValidEmpNum will be called again.
Use while loop for this to make it work properly.
▪ Hire date
Follow the Unified Modeling Language diagram below to create Employee
fields, constructors and the appropriate accessor and mutator methods
for the class.Employee Class UML
Next, write a class named ProductionWorker that inherits from
the Employee class. The ProductionWorker class stores data about an
employee that is a production worker. The ProductionWorker class
should have fields to hold the following information:
▪ Shift (an integer) Validate the shift value. Make sure the user to enter
only 1 or 2.
▪ Hourly pay rate (a double) No need for validation for this one.
The workday is divided into two shifts: day and night. The shift field
will be an integer value representing the shift that the employee works.
The day shift is shift 1, and the night shift is shift 2.
Write two constructors and the appropriate accessor and mutator
methods for the class. Please follow the UML below for it:

Demonstrate the classes by writing a program that uses
ProductionWorker objects. Here is how you do this: Create a class
named which has the main method in it. We will create
objects of ProductionWorker class. One of these objects is using the
overloaded constructor to set the values of Employee Name, number,
Date of Hire, shift and payRate.
The other object will ask for user inputs to set those values. For more
details, see the sample output.

Project6 CECS277

SavingDemo is the main class.
BankAccount and SavingsAccount Classes
Design an abstract class named BankAccount to hold the following data for a
bank account:
▪ Balance
▪ Number of deposits this month
▪ Number of withdrawals
▪ Annual interest rate
▪ Monthly service charges
The class should have the following methods:
Next, design a SavingsAccount class that extends the BankAccount class.
The SavingsAccount class should have a status field to represent an
active or inactive account. If the balance of a savings account falls below
$25, it becomes inactive. (The status field could be a boolean variable.)
No more withdrawals can be made until the balance is raised above $25,
at which time the account becomes active again. The savings account
class should have the following methods:
Constructor The constructor should accept arguments for the balance and annual
interest rate.
deposit A method that accepts an argument for the amount of the deposit.
The method should add the argument to the account balance. It
should also increment the variable holding the number of
deposits.
withdraw A method that accepts an argument for the amount of the
withdrawal. The method should subtract the argument from the
balance. It should also increment the variable holding the number
of withdrawals.
calcInterest A method that updates the balance by calculating the monthly
interest earned by the account, and adding this interest to the
balance. This is performed by the following formulas:
Monthly Interest Rate = (Annual Interest Rate/12)
Monthly Interest = Balance * Monthly Interest Rate
Balance = Balance + Monthly Interest
monthlyProcess A method that subtracts the monthly service charges from the
balance, calls the calcInterest method, then sets the variables that
hold the number of withdrawals, number of deposits, and monthly
service charges to zero.
withdraw A method that determines whether the account is inactive
before a withdrawal is made. (No withdrawal will be allowed if
the account is not active.) A withdrawal is then made by calling
the superclass version of the method.
deposit A method that determines whether the account is inactive
before a deposit is made. If the account is inactive and the
deposit brings the balance above $25, the account becomes
active again. The deposit is then made by calling the superclass
version of the method.
monthlyProcess Before the superclass method is called, this method checks the
number of withdrawals. If the number of withdrawals for the
month is more than 4, a service charge of $1 for each
withdrawal above 4 is added to the superclass field that holds
the monthly service charges. (Don’t forget to check the account
balance after the service charge is taken. If the balance falls
below $25, the account becomes inactive.)
s
Sample output in one run:

Project7 CECS277

Part 1:Essay Class
Design an Essay class that inherits from the GradedActivity class. The Essay class should
determine the grade a student receives on an essay. The student’s essay score can be up to
100 and is determined in the following manner:
Grammar: 30 points
Spelling: 20 points
Correct length: 20 points
Content: 30 points
Demonstrate the class in a simple program.
Assign scores to the object.
Grammer = 25 points, Spelling = 18 points,
Length = 20 points, and Content = 25 points.
Essay termPaper = new Essay();
termPaper.setScore(25.0, 18.0, 20.0, 25.0);
Sample output:
Part 2 : Course Grades
In a course, a teacher gives the following tests and assignments:
 A lab activity that is observed by the teacher and assigned a numeric score.
 A pass/fail exam that has 10 questions. The minimum passing score is 70.
 An essay that is assigned a numeric score.
 A final exam that has 50 questions.
Write a class named CourseGrades. The class should have an array
of GradedActivity objects as a field. The array should be named grades.
The grades array should have four elements, one for each of the assignments previously
described. The class should have the following methods:
Demonstrate the class in a program.
Following classes extends from GradedActivity…
Essay class: please see the class description in step one.
Private Member Fields:
numQuestions: int
pointsEach: double
numMissed: int
Public methods:
Overloaded constructor: void
accepts as arguments the number of questions on the exam and the number of questions the student
missed.
getPointsEach(): double
getNumMissed(): int
FinalExam class:
Private Member Fields:
minPassingScore: double // Minimum passing score
Public methods:
Overloaded constructor
Accept the minimum passing score as its argument

getGrade: char
The getGrade method returns a letter grade determined from the score field. This method overrides the
superclass method.

Private Member Fields:
numQuestions: int
pointsEach: double
numMissed: int
Public methods:
Overloaded constructor: void
accepts as arguments the number of questions on the exam and the number of questions the student
missed.
getPointsEach(): double
getNumMissed(): int
PassFailExam class extends from PassFailActivity
PassFailActivity class:
Sample output for these specific inputs:
Create an object for the lab grade and set the lab score to 85.
Create an object for the pass/fail exam.
20 total questions, 3 questions missed, minimum passing score is 70.
Create an object for the essay grade and Set the essay scores.
Grammer = 25, spelling = 18, length = 17, content = 20.
Create an object for the final exam. 50 questions, 10 missed.
Part 3: Analyzable Interface
Modify the CourseGrades class you created in part2 so that it implements the following interface:
The getAverage method should return the average of the numeric scores stored in the grades array.
The getHighest method should return a reference to the element of the grades array that has the highest
numeric score. The getLowest method should return a reference to the element of the grades array that has
the lowest numeric score. Demonstrate the new methods in a complete program.
In UML, the empty diamond
signifies an aggregation.
Aggregation is a variant of the
“has a” association relationship
This relation is stronger than a
simple association. In this case a
CourseGrades aggregates
GradedActivity.

Project8 CECS277

Read all words from the test1.txt file and add them to a
map whose keys are the first letters of the words and
whose values are sets of words that start with that same
letter. Then print out the word sets in alphabetical order.
Name your class java file as FirstLetterMap.java. Provide
your solution for this one as project8.jar.

Project9 CECS277

Problem Description:
Implement a to do list. Tasks have a priority between 1 and 9, and a description.
When the user enters the command add priority description, the program adds a new
task. When the user enters next, the program removes and prints the most urgent
task. The quit command quits the program.
Use a priority queue in your solution.
Sample Output:
To Do List – Please enter an option
add priority description (add a new task)
next (remove and print most urgent task)
quit (exit this program)
> add 3 description of new task
> add 4 even newer task
> add 2 least important task
> next
least important task
> next
description of new task
> next
even newer task
> quit
Press any key to continue . . .
Here is a tester for assignment. It is not complete. You will need to make tests for the equals and
hashcode methods to prove that they work.

Project 10 CECS277

Assume we have three different credit cards: Visa, Discover, and AmericanExpress
options and all of them implement abstract class CreditCard. You need to instantiate one
of these classes, but you don’t know which of them, it depends on the user. This is a
perfect scenario for the Factory Method design pattern. Please see the UML diagram and
sample output below for details of how to implement this design.
UML DIAGRAM
Sample output:
In CreditCardDemo: You should be creating an instance of CardFactory and based on user input
you will instantiate the right credit card. Values for credit limit and annual Charges is hard coded.
Program is looping until user enters quit.

Project 11 CECS277

We are going to design our banking system to explore State design pattern.
Assume that we want to develop a banking system with these three kinds of different accounts.
Here are the scenarios
• If the balance in the account is greater than 0 and less than $20000 the status of the
account is normal(NormalAccountState). At this time, users can either deposit to the
account or withdraw money from the account. There is no interest gain for this account.
• If the balance in the account is less than or equal to 0. Then the status of the account is
Restricted(RestrictedAccountState). At this time, users can deposit but it can’t withdraw
money from the account. No interest for this account.
• If the balance in the account is equal or greater than $20000.00. Then the status of the
account is (GoldAccountState). At this time, the user can deposit into the account and can
withdraw money from the account. The interest will be calculated.
• According to different balances, the above three states can be converted to each other.
In these three states, NormalAccountState, RestrictedAccountState, and
GoldAccountState account, objects have different behaviors.
Method deposit() is used to deposit, withdraw() is used to withdraw money,
calculateInterest() is used to calculate interest, stateChangeCheck () is used to
determine whether to make a deposit or withdrawal operation according to the balance
after each deposit and withdrawal operation
The same method may have different implementations in different states.
Account.java
The account class combines an AccountState class, which is used to identify the status of the
current account. At the same time, when an operation request is made to an account, the
corresponding operation and permission restrictions are different according to different account
states. The implementation principle of making different operations according to different states
is polymorphism.
AccountState.java
abstract class of account status
In order to make the system more flexible and extensible, and encapsulate the common behavior in
each state, we need to abstract the state and introduce the role of abstract state class.
NormalAccountState.java
If the balance in the account is greater than 0 and less than $20000 the status of the account is
normal(NormalAccountState).
RestrictedAccountState.java
If the balance in the account is less than or equal to 0. Then the status of the account is
Restricted(RestrictedAccountState). At this time, users can deposit but it can’t withdraw money
from the account. No interest for this account.
GoldAccountState.java
If the balance in the account is equal or greater than to $20000.00. Then the status of the account
is (GoldAccountState). At this time, the user can deposit into the account and can withdraw
money from the account. The interest will be calculated by day. To calculate the interest, use hard
coded value of 0.01 over one year. The display value in the sample output is the monthly interest.

Sample Output: