For this assignment you will be constructing 2 new classes, Project and Assignment6 which is a test driver for the class Project. (2 files)

Class Project: The Project class describes a project that people can participate in. It must have the following attributes:

name type Description
projName String name of a project
projNumber int number of a project
projLocation String location of a project
initialFunding double initial funding of a project
spending double spending of a project
currentBalance double current balance of a project

Here are the methods for class Project:

  • public Project(double amount) This constructor initializes all strings to "?" and the project number to 0. The varibales spening is assigned to 0.0. currentBalance and initial funding are assigned to the amount passed as a parameter .
  • public String getName() Accessor method
  • public int getNumber() Accessor method
  • public String getLocation() Accessor method
  • public void setName(String aName) Mutator method
  • public void setNumber(int aNumber) Mutator method
  • public void setLocation(String aLocation) Mutator method
  • public boolean addExpenditure(double amount) The following method should be provided to change the project budget. If the parameter value is positive and is less than or equals to project budget, the current budget should be re-computed as initial funding -spending, and the method should return true. All the variables related to budget funding needs to be up-dated. Otherwise, the method should not change any value and return false
  • public String toString() The toString() method constructs a string of the following format: nProject Name:tProject Namen Project Number:tProject Numbern Project Location:tProject Locationn Initial Fundingt$0.00n Spendingt$0.00n Current Balancet$0.00n

Hints: you can make use of the DecimalFormat or NumberFormat class in java.text package to format initialFunding, spending, and currentBalance, having two digits after the decimal point "$0.00".

Assignment6 Class:

The driver program will allow the user to interact with your class Project. The purpose of this class is to handle all user input and screen output. The main method should start by displaying the following menu in this format:

ChoicettActionn
------tt------n
AttAdd Projectn
DttDisplay Projectn
QttQuitn
RttAdd Expendituren
?ttDisplay Helpnn

Next, the following prompt should be displayed:

What action would you like to perform?

Read in the user input and execute the appropriate command. After the execution of each command, re-display the prompt. Commands should be accepted in both lowercase and uppercase.

Add Project

Your program should display the following prompt:

Please enter the project information:
Enter a project name:

Read in the user input. Then the following prompt:

Enter a project number:

Read in the user input. Then the following prompt:

Enter a project location:

Read in the user input. Then the following prompt:

Enter a project initial funding:

Read in the user input, and use the constructor of the Project class to initialize a new Project object, project1, and set the values read from the user input, using the mutator (setter) methods of the Project class. Note that there is only one Project object in this assignment. Thus when "Add Project" option is selected more than once, the new one overwrites the old Project object.

Display Project (option A)

Your program should display the Project information using the toString method of the Project class. The toString method is used together with System.out.print method.

Quit (aption Q)

Your program should stop executing and output nothing.

Add Expenditure (option R)

Your program should display the following prompt:

Please enter any additional expenditure:

Read in the user input and update the budget of the project accordingly by calling the addExpenditure method of the project object. If it returns false, then it should display the error message: The entered expenditure is not accepted.

Display Help (option ?)

Your program should redisplay the "choice action" menu.

Invalid Command

If an invalid command is entered, display the following line:

Unknown action

Sample Output: user input is in RED

Choice Action
------ ------
A Add Project
D Display Project
Q Quit
R Add Expenditure
? Display Help

What action would you like to perform?
A
Please enter the project information:
Enter a project name:
Helping Children Project
Enter a project number:
123
Enter a project location:
Phoenix
Enter a project initial funding:
2450000
What action would you like to perform?
d

Project Name: Helping Children Project
Project Number: 123
Project Location: Phoenix

Initial Funding $2,450,000.00
Spending $0.00
Current Balance $2,450,000.00
What action would you like to perform?
r
Please enter any additional expenditure:
3500
What action would you like to perform?
d

Project Name: Helping Children Project
Project Number: 123
Project Location: Phoenix

Initial Funding $2,450,000.00
Spending $3,500.00
Current Balance $2,446,500.00
What action would you like to perform?
r
Please enter any additional expenditure: 20000
What action would you like to perform? d

Project Name: Helping Children
Project Project Number: 123
Project Location: Phoenix

Initial Funding $2,450,000.00
Spending $23,500.00
Current Balance $2,426,500.00
What action would you like to perform?
q
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.