The Plastik Chicken Company needs a new program to print certain information bas
ID: 3537168 • Letter: T
Question
The Plastik Chicken Company needs a new program to print certain information based on employee data. Write a program that meets the conditions as described below. Make sure that you code includes you name, class, section, date and a brief description as a comment header. Also be sure that your code included comments and it properly formatted.
Part 1:
Prompt the user for the following information for two employees
First Name, Last Name, Street Address, City, State, Zip code and phone number, Pay Rate, and hours worked.
Display the following information for each employee: (Display in a descriptive way using full sentences)
LAST NAME , FIRST NAME , INDEX VALUE OF LAST LETTER OF LAST NAME
CITY, STATE, ZIPCODE
LAST 4 DIGITS of PHONE NUMBER
PAY RATE, HOURS WORKED, TOTAL PAY
Part 2:
Also print the following information based on the condition of the data of one of the employees.
1)
If employees pay rate is less than $5.00 print the message %u2018You need a raise!%u2019, if it is greater than 5.00 but less than $10.00 print %u201CYour pay is about $ PAYRATE dollars%u201D (where PAYRATE is the actual amount but casted as a integer value). If the pay rate is greater than 10.00, print the message %u2018Good Job!%u2019.
2)
Based on the total pay amount, construct your own series of IF/ELSE-IF / ELSE statements (create at least 6 separate statements). You can use information based on one employee, both or in combination. Use the flowing at least once:
-A compound statement (Use && and ||)
-One statement based on the first letter of a first name
-Compare the last names of both employees to see if they are the same
-To see if a string contains a certain letter or substring
The test conditions can be based on any data or subsets of data that have been entered by the user.
Explanation / Answer
Completely exceutable code by me
Rate me 5 stars
import java.text.DecimalFormat;
import java.util.*;
class Employee
{
String first;
String last;
String add;
String city;
String zip;
String state;
String phone;
double payrate;
double hrs;
double total;
public Employee()
{
first="";
last="";
add="";
city="";
zip="";
state="";
phone="";
payrate=0;
hrs=0;
total=0;
}
}
class Mukesh
{
public static void main(String[] args)
{
Scanner s = new Scanner (System.in);
Employee e1=new Employee();
Employee e2=new Employee();
System.out.println("Enter the first name");
e1.first=s.next();
System.out.println("Enter the last name");
e1.last=s.next();
System.out.println("Enter the address");
e1.add=s.next();
System.out.println("Enter the city");
e1.city=s.next();
System.out.println("Enter the state");
e1.state=s.next();
System.out.println("Enter the zip code");
e1.zip=s.next();
System.out.println("Enter the phone");
e1.phone=s.next();
System.out.println("Enter the payrate");
e1.payrate=s.nextDouble();
System.out.println("Enter the hrs");
e1.hrs=s.nextDouble();
e1.total=e1.hrs*e1.payrate;
System.out.println("Enter the first name");
e2.first=s.next();
System.out.println("Enter the last name");
e2.last=s.next();
System.out.println("Enter the address");
e2.add=s.next();
System.out.println("Enter the city");
e2.city=s.next();
System.out.println("Enter the state");
e2.state=s.next();
System.out.println("Enter the zip code");
e2.zip=s.next();
System.out.println("Enter the phone");
e2.phone=s.next();
System.out.println("Enter the payrate");
e2.payrate=s.nextDouble();
System.out.println("Enter the hrs");
e2.hrs=s.nextDouble();
e2.total=e2.hrs*e2.payrate;
System.out.println("The last name of 1st employee: "+e1.last);
System.out.println("The first name of 1st employee: "+e1.first);
System.out.println("Index value of last letter of last name 1st employee: "+e1.last.substring(e1.last.length()-1,e1.last.length()));
System.out.println("The city of 1st employee: "+e1.city);
System.out.println("The state of 1st employee: "+e1.state);
System.out.println("The zipcode of 1st employee: "+e1.zip);
System.out.println("The last 4 digits of phone number of 1st employee: "+e1.phone.substring(e1.phone.length()-4,e1.phone.length()));
System.out.println("The payrate of 1st employee: "+e1.payrate);
if(e1.payrate<=5)
{
System.out.println("You need a raise!");
}
else if((e1.payrate<10)&&(e1.payrate>5))
{
System.out.println("Your pay is about $ "+e1.payrate+" dollars");
}
else
{
System.out.println("Good Job!");
}
System.out.println("The hrs of 1st employee: "+e1.hrs);
System.out.println("The total pay of 1st employee: "+(e1.hrs*e1.payrate));
System.out.println("The last name of 1st employee: "+e2.last);
System.out.println("The first name of 1st employee: "+e2.first);
System.out.println("Index value of last letter of last name 1st employee: "+e2.last.substring(e2.last.length()-1,e2.last.length()));
System.out.println("The city of 1st employee: "+e2.city);
System.out.println("The state of 1st employee: "+e2.state);
System.out.println("The zipcode of 1st employee: "+e2.zip);
System.out.println("The last 4 digits of phone number of 1st employee: "+e2.phone.substring(e2.phone.length()-4,e2.phone.length()));
System.out.println("The payrate of 1st employee: "+e2.payrate);
if(e2.payrate<=5)
{
System.out.println("You need a raise!");
}
else if((e2.payrate<10)&&(e2.payrate>5))
{
System.out.println("Your pay is about $ "+e2.payrate+" dollars");
}
else
{
System.out.println("Good Job!");
}
System.out.println("The hrs of 1st employee: "+e2.hrs);
System.out.println("The total pay of 1st employee: "+(e2.hrs*e2.payrate));
if(e1.total > e2.total)
{
System.out.println("Employee 1 earned a lot");
}
else if(e2.total > e1.total)
{
System.out.println("Employee 2 earned a lot");
}
else
{
System.out.println("Both earned equally");
}
if(e1.first.substring(e1.first.length()-1, e1.first.length()).equals(e2.first.substring(e2.first.length()-1, e2.first.length())))
{
System.out.println("Both have first name first letter same");
}
if(e1.last.equals(e2.last))
{
System.out.println("Both have same last name");
}
if(e1.first.contains("j"))
{
System.out.println("Employee 1 has j in its first name");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.