Coding
COSC 1437 – LAB4
TITLE
Object Oriented Programming with data type class and driver class
Selection Statements - SaleRepresentative and SalaryOfRepresentative
HOW TO DO PART 2
*From now and on yourLastName will be changed to your last name.
*Your program should change White to your last name.
*Your program should change McKINLEY WHITE to your name.
*Change Mary Lane to the name of user who is using the Investment Application entered from the keyboard.
*Write the file name as the first comment line at the top of the program.
*After running your program, get the picture of the output window from your program with your name on to paste at the bottom of the pseudo-code to turn in.
*Step1: Read the requirement of each part; write the pseudo-code in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Lab4_pseudoCode_yourLastName
*Step2:
-start editor (for example eClipse) create the project with the following project name:
Part2: FA2021_LAB4PART2_yourLastName
-add data type class and driver class:
Part2: data type class FA2021_SaleRepresentative_yourLastName
and driver class FA2021_SalaryOfSaleRepresentative_yourLastName
*Step3: read instruction in part 2, provide UML for data type class and write the pseudo-code (or draw the flowchart) for main(), then write the code for data type class and driver classs
*Step:4 compile and run the program
*Step5: debug if there are any errors to complete the program
LAB4 PART1 (ANSWER 4 QUESTIONS)
Use the word document to write the answers of the following questions:
QUESTION 1:
Suppose that we have the following piece of the code in main()
float faValue1, faValue2;
Scanner keyboard = new Scanner(System.in);
System.out.println(“Enter a decimal number for faValue2: “);
faValue2 = keyboard.nextFloat();
//Continue providing an IF STATEMENT that assigns 9.17 to faValue1 when faValue2 is less than 18.34
. . . .
QUESTION 2:
Suppose that we have the following piece of the code in main()
float faValue1, faValue2;
System.out.println( “Enter a decimal number for faValue2: “);
faValue2 = keyboard.nextFloat() ;
//Continue providing an IF..ELSE STATEMENT that performs the following:
// assigns 9.17 to faValue1 when faValue2 is less than or equal to 18.34
// otherwise assign 20.21
QUESTION 3:
Using the following chart, write an IF..ELSE..IF STATEMENT to select the commission rate depending on the sale amount listed on the left column:
|
Sale Amount |
Commission Rate |
|
Less than or equal $9000 |
2.49% |
|
Greater $8000 and up to $12500 |
3.29% |
|
Over $12500 |
4.19% |
QUESTION 4:
Suppose we have the following lines of code in main()
int iFaValue1, iFaValue2;
Scanner keyboard = new Scanner(System.in);
System.out.println( “Enter the first integer: “;
iFAValue1 = keyboard.nextInt();
System.out.println( “Enter the second integer: “;
iFaValue2 = keyboard.nextInt();
//Continue providing a NESTED IF STATEMENT that performs the following
// When iFaValue1 is greater than 917 and iFaValue2 is greater than or equal to 600 and
// When iFaValue1 is less than iFaValue2 then display the message:
// “iFaValue1 and iFaValue2 are greater than 600 and iFaValue2 is greater than iFaValue1”
QUESTION 5:
Suppose we have the following lines of code in main()
int selection;
Scanner keyboard = new Scanner(System.in);
System.out.println(“Enter one number in the range 1 to 4 to select the task: “);
selection = keyboard.nextInt();
if (selection == 1 || selection == 2 )
{
System.out.println( “Your selection is 1 or your selection is 2 ” ) ;
}
else if (selection == 3)
{
System.out.println( “Your selection is 3” );
}
else if (selection == 4 )
{
System.out.println( “Your selection is 4.” );
}
else
{
System.out.println( “Invalid. Select again please”);
}
Question: Convert the above IF..ELSE..IF STATTEMENT into a SWITCH STATEMENT
LAB4 PART2
READ THE REQUIREMENT, CREATE THE PSEUDO-CODE BEFORE WRITING THE CODE
REQUIREMENT Applying Object Oriented Programming and using Java to provide the application to help the company to calculate the salary of Sale Representatives of the company and print out the month salary slip at the end of the month
The project must include the data type FA2021_SaleRepresentative_yourLastName and the driver class FA2021_SalaryOfSaleRepresentative_yourLastName.
DATATYPE CLASS
-The class FA2021_SaleRepresentative_yourLastName includes name (string), employee id (string), and the sale amount (float) are read from the keyboard provided from users.
-It should include no-argument constructor, parameterized constructor, method to calculate the commission amount, method to calculate the bonus amount, method to calculate salary in month and the method toString() to create the output string of the salary payroll split (see below) where base salary = $2200
FORMULA:
The salary of the month = base salary + commission amount + bonus amount
The commission rate and bonus rate to calculate the commission amount and bonus amount should be read from the following table that depend on the sale amount the Sale Representative made during the month:
The salary payroll split in the following format in the
File FA2021_SalaryOfRepresentative_Smith.java
SALE COMPANY JAMES SMITH
Today: 08/31/21
----------------------------------------------------------
Name of Sale Representative: Mary Lane
Employee Id: 1234567
Sale amount: 8500.00
----------------------------------------------------------
Base salary: 2200.00
Commission Amount: 0.00
Bonus amount: 0.00
Salary: 2200.00
----------------------------------------------------------
OR
File FA2021_SalaryOfRepresentative_Smith.java
SALE COMPANY JAMES SMITH
Today: 08/31/21
----------------------------------------------------------
Name of Sale Representative: Mary Lane
Employee Id: 1234567
Sale amount: 12850.00
----------------------------------------------------------
Base salary: 2200.00
Commission Amount: 461.32
Bonus amount: 23.72
Salary: 2685.04
----------------------------------------------------------
OR
File FA2021_SalaryOfRepresentative_Smith.java
SALE COMPANY JAMES SMITH
Today: 08/31/21
----------------------------------------------------------
Name of Sale Representative: Mary Lane
Employee Id: 1234567
Sale amount: 15875.00
----------------------------------------------------------
Base salary: 2200.00
Commission Amount: 569.91
Bonus amount: 127.49
Salary: 2897.40
---------------------------------------------------------
DRIVER CLASS
Create the pseudo-code or flowchart before writing the code of the driver class
Providing the application FA2021_SalaryOfSaleRepresentative_yourLastName that read information of one sale representative about name (string), employee id (string), and the sale amount (float) tne use the objectt of the data type class FA2021_SaleRepresentative_yourLastName to access the method toString() to display the payroll slip as requested
HOW TO TURN IN THE LAB
You should turn in the following files: (yourLastName should be your last name)
FA2021_LAB4PART1_YourLastName.docx (part 1)
UML Pseudo-code and the output pictures of part2
FA2021_SaleRepresentative_yourLastName.java
FA2021_SalaryOfSaleRepresentative_yourLastName.java
FA2021_SaleRepresentative_yourLastName.class
FA2021_SalaryOfSaleRepresentative_yourLastName.class
IF YOU GET ANY PROBLEM TO SUBMIT FILEs .class YOU CAN COMPRESS ALL PROJECT INTO ONE FILE .zip or .rar TO UPLOAD TO eCampus
HOW TO GRADE THE LAB
|
Items |
Score |
|
Turn in on time |
3 |
|
PART1 |
|
|
Question 1 |
1 |
|
Question 2 |
1 |
|
Question 3 |
2 |
|
Question 4 |
1 |
|
Question 5 |
2 |
|
PART2 |
|
|
Submit all files requested |
1 |
|
Psuedo-code(main) – UML (data type class) -output pictures |
2 |
|
Data type class |
|
|
Define data members |
1 |
|
No argument constructor – parameterized constructor |
2 |
|
Method to calculate commission |
1 |
|
Method to calculate bonus |
2 |
|
Method to calculate total salary in month |
1 |
|
Method toString() display the salary slip as requested format |
2 |
|
Driver class |
|
|
Read input |
1 |
|
Create the object of data type class |
1 |
|
Display the salary slip by calling the method toString() |
1 |
|
Write the comment – file name at the top of file |
2 |
|
Compile success – qualified all the requirements |
3 |
|
Total` |
30 |