Question

In: Computer Science

Design and implement an application that can compute the weekly pay for different students at a college.

In Java 

Design and implement an application that can compute the weekly pay for different students at a college. Students (all with a name, major, GPA) can be undergraduate or graduate students. Undergraduate students can be volunteers to be tuto rs or teaching assistants. Graduate students can be teaching assistants or research assistants. Volunteer tuto rs are not paid anything. Undergraduate teaching assistants are paid $15 per hour and can work a maximum of 20 hours per week. Graduate teaching assistants are paid $20 per hour and can work a maximum of 20 hours per week. Graduate research assistants are paid $30 per hour and can work 25 works a week. Create a small array (size 4) to hold different students. Then create a driver class to display the different students and their weekly pay.

Solutions

Expert Solution

import java.util.Scanner;

// Enum to hold type of graduate
enum GraduateType
{
GRADUATE,UNDERGRADUATE;
}

// Enum to hold assistant type
enum ASSISTANTTYPE
{
TUTOR,TEACHINGASSISTANT,RESEARCHASSISTANT;
}
class Student
{
  
// each student will hold following details
String studentName; // Placeholder for student name
double GPA;
String major;
GraduateType gradOrUnderGrad; // boolean to check if studnet is grad or undergrad
ASSISTANTTYPE assistantTtpe;
double hoursWorked; // the number of hours worked in a week
  
  
// parametrised constructor, used to create object with all given details
Student(String sname,double gpa,String majorhere,GraduateType gType,ASSISTANTTYPE assType,double hWorked)
{
studentName = sname;
GPA = gpa;
major = majorhere;
gradOrUnderGrad = gType;
assistantTtpe = assType;
hoursWorked = hWorked;
}
  
// getters
GraduateType getGraduateType()
{
return gradOrUnderGrad;
}
ASSISTANTTYPE getAssistantType()
{
return assistantTtpe;
}
  
  
// to check for each graduate type and assistant type what is the allowed maximum hours
int allowedMaximumWorkHours()
{
int allowedMaxHours = 0;
if(GraduateType.valueOf("UNDERGRADUATE") == gradOrUnderGrad && ASSISTANTTYPE.valueOf("TEACHINGASSISTANT") == assistantTtpe)
{
allowedMaxHours = 20;
}
else if(GraduateType.valueOf("GRADUATE") == gradOrUnderGrad && ASSISTANTTYPE.valueOf("TEACHINGASSISTANT") == assistantTtpe)
{
allowedMaxHours = 20;
}
else if(GraduateType.valueOf("GRADUATE") == gradOrUnderGrad && ASSISTANTTYPE.valueOf("RESEARCHASSISTANT") == assistantTtpe)
{
allowedMaxHours = 25;
}
return allowedMaxHours;
}
// to check for each graduate type and assistant type what is the allowed pay rate
int getPayRate()
{
int finalPayRate = 0;
if(GraduateType.valueOf("UNDERGRADUATE") == gradOrUnderGrad && ASSISTANTTYPE.valueOf("TUTOR") == assistantTtpe)
{
finalPayRate = 0;
}
else if(GraduateType.valueOf("UNDERGRADUATE") == gradOrUnderGrad && ASSISTANTTYPE.valueOf("TEACHINGASSISTANT") == assistantTtpe)
{
finalPayRate = 15;
}
else if(GraduateType.valueOf("GRADUATE") == gradOrUnderGrad && ASSISTANTTYPE.valueOf("TEACHINGASSISTANT") == assistantTtpe)
{
finalPayRate = 20;
}
else if(GraduateType.valueOf("GRADUATE") == gradOrUnderGrad && ASSISTANTTYPE.valueOf("RESEARCHASSISTANT") == assistantTtpe)
{
finalPayRate = 30;
}
return finalPayRate;
}
//// to check for each graduate type the allowed combination of assistant type
boolean isAllowedCombination()
{
boolean isAllowed = false;
//System.out.println(getGraduateType());
//System.out.println(getAssistantType());
if(getGraduateType() == GraduateType.valueOf("UNDERGRADUATE"))
{
if(getAssistantType() == ASSISTANTTYPE.valueOf("TUTOR") || getAssistantType() == ASSISTANTTYPE.valueOf("TEACHINGASSISTANT"))
{
isAllowed = true;
}
}
else if(getGraduateType() == GraduateType.valueOf("GRADUATE"))
{
if(getAssistantType() == ASSISTANTTYPE.valueOf("RESEARCHASSISTANT") || getAssistantType() == ASSISTANTTYPE.valueOf("TEACHINGASSISTANT"))
{
isAllowed = true;
}
}
return isAllowed;
}
}
public class Main
{
public static void main(String[] args)
{
System.out.println( "Student Weekly Payroll Program\n\n"); // Tells program to show Welcome Message
Scanner input;
Student[] array = new Student[4];
  
  
// creating sample of 4 students
Student s1 = new Student("Bhavana",9.0,"CSE",GraduateType.valueOf("UNDERGRADUATE"),ASSISTANTTYPE.valueOf("TUTOR"),20);
Student s2 = new Student("Arpitha",8.0,"ISE",GraduateType.valueOf("UNDERGRADUATE"),ASSISTANTTYPE.valueOf("TEACHINGASSISTANT"),20);
Student s3 = new Student("Rakesh",7.0,"ECE",GraduateType.valueOf("GRADUATE"),ASSISTANTTYPE.valueOf("TEACHINGASSISTANT"),20);
Student s4 = new Student("Amruth",6.0,"EEE",GraduateType.valueOf("GRADUATE"),ASSISTANTTYPE.valueOf("RESEARCHASSISTANT"),40);
  
array[0] = s1;
array[1] = s2;
array[2] = s3;
array[3] = s4;
  
// iterating over each student and calculating weekly pay.
// if any student has worked beyong allowed limit of working hours/
  
// pay is given only for allowed hours.
// if within limit to no of hours worked pay is calulated,
for(int i=0;i<4;i++)
{
if(array[i].isAllowedCombination())
{
int payRate = 0;
double totalWeeklyPay =0.0;
//System.out.println( "Is allowed combination");
System.out.println( "Student Number:"+i);
System.out.println( "Student Name:"+array[i].studentName);
System.out.println( "Graduate Type:"+array[i].getGraduateType());
System.out.println( "Assistant Type:"+array[i].getAssistantType());
payRate = array[i].getPayRate();
System.out.println("Pay Rate:"+payRate);
System.out.println("Hours Worked:"+array[i].hoursWorked);
System.out.println("Allowed Maximum Hours:"+array[i].allowedMaximumWorkHours());
if(array[i].hoursWorked <= array[i].allowedMaximumWorkHours())
{
System.out.println(" number of hours worked is within range");
totalWeeklyPay = payRate * array[i].hoursWorked;
}
else if(array[i].hoursWorked > array[i].allowedMaximumWorkHours())
{
System.out.println(" number of hours worked is outside the range range");
totalWeeklyPay = payRate * array[i].allowedMaximumWorkHours();
}
System.out.println("Total Weekly pay:"+ totalWeeklyPay);
System.out.println("-------------------------------");
}
else
{
System.out.println( "Entered Graduate type and assistance type are not allowed");
}
}
}
}

output:


Related Solutions

Compute the deductions, net pay, and accumulated gross earnings for each weekly pay period. Assume that...
Compute the deductions, net pay, and accumulated gross earnings for each weekly pay period. Assume that Joseph is single and that $28.25 was withheld for medical insurance (pre-tax) and $20 for his United Way contribution. Use the wage bracket method to determine federal income tax. Round answers to the nearest hundredth. Gross Earnings(650.95) Allow.(1) Fed. Inc. Tax Social Security (6.2%)Medicare (1.45%) Medical Insurance Pre-tax United Way Total Deductions Net Pay Accum. Gross Earnings ($1,558.90)
Design and implement an application that reads an integer value and prints the sum of all...
Design and implement an application that reads an integer value and prints the sum of all even integers between 2 and the input value, inclusive. Print an error message if the input value is less than 2 and prompt accordingly so that the user can enter the right number. Your program file will be called YourLastNameExamQ2
Java - Design and implement an application that creates a histogram that allows you to visually...
Java - Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered. Sample...
(Python) Implement a function to compute a sum that can compute sum for an arbitrary number...
(Python) Implement a function to compute a sum that can compute sum for an arbitrary number of input integers or float numbers. In other words, calls like this should all work: flexible_sum(x1, x2) # sum of two integer or float numbers or strings x1 and x2 flexible_sum(x1, x2, x3) # sum of 3 input parameters and can also handle a single input parameter, returning it unchanged and with the same type, i.e.:   flexible_sum(1) returns 1 and can accept an arbitrary...
C++ Task: Compute the weekly pay for each employee at the Wahoo Widget Company. For each...
C++ Task: Compute the weekly pay for each employee at the Wahoo Widget Company. For each employee, you will calculate the base pay according to the appropriate salary category, and then subtract taxes and deductions. Write the program in C++ only. Input: For each employee, read an employee ID (a 4-digit integer) and a salary category code (see below). Then read whatever other information might be needed to compute a net salary for that person. Because of occasional employee turn-over,...
programing language JAVA: Design and implement an application that reads a sentence from the user, then...
programing language JAVA: Design and implement an application that reads a sentence from the user, then counts all the vowels(a, e, i, o, u) in the entire sentence, and prints the number of vowels in the sentence. vowels may be upercase
A, B:   Design and Implement a C# windows form application to ask the user for 10...
A, B:   Design and Implement a C# windows form application to ask the user for 10 integer numbers, sort them in ascending order and display the sorted list. Use bubble sort technique to sort the array elements and do not use any built-in sort method to sort the array elements.                                                        [02] C:    Test and evaluate your program by inputting variety of values.
A, B:    Design and Implement a C# windows form application to encrypt and decrypt text....
A, B:    Design and Implement a C# windows form application to encrypt and decrypt text. The application use to receive a string and display another encrypted string. The application also decrypt the encrypted string. The approach for encryption/decryption is simple one i.e. to encrypt we will add 1 to each character, so that "hello" would become "ifmmp", and to decrypt we would subtract 1 from each character.    C:   Test and evaluate application by applying different strings.      ...
Three firms can supply a college with some application software. Each firm has a different pricing...
Three firms can supply a college with some application software. Each firm has a different pricing structure: the first firm provides a site license which costs $130,000 and can be used by anyone at the college. The second firm charges $1000 per user and the third charges a fixed amount of $40,000 for the first 60 users and $500 for each additional user. Draw a graph of each cost function on the same set of axes. What advice can you...
Design and implement a Demand Paging virtual memory simulator! It must be a text based application...
Design and implement a Demand Paging virtual memory simulator! It must be a text based application (NOT a GUI based one). You can use the C/C++ or Java programming language. The following algorithms must be implemented: FIFO, OPT, LRU and LFU. The application must simulate the execution of each of these algorithms on a hypothetical computer having only N physical frames (numbered from 0 to N-1, N<8), assuming that the single process that is running has a virtual memory of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT