Calculate Pay

my question is, how do i calculate and have it display on the display screen?

Employee ID Employee Name Hours Worked 1 Alabaster Snowball 40 2 Bushy Evergreen 25.5 3 Pepper Minstix 45 4 Sugarplum Mary 42

  1. Using a function, will calculate the pay. Hours over 40 receive time-and-a-half pay. All employees are paid minimum wage of Alaska 9.84)
  2. Add the pay to the totals.
  3. Accumulate the total number of hours worked, the total number of hours of overtime, and the total amount of pay.

What I have all ready int x=10; int y=70; PFont f; float hoursWorked[];

void setup() { size(1000,400); fill(0); f = loadFont("Calibri-30.vlw"); textFont(f,30); // load the files String [] stuff = loadStrings("hoursWorked.txt");

String [] employeeName = loadStrings("employeeName.txt");

String[] id = loadStrings("id.txt");

hoursWorked=float(split(stuff[0], ','));

for (int i = 0; i < 4; i++) {

print(id[i]);
print("\t");
print(employeeName[i]);
print("\t");
print(hoursWorked[i]);
println();
//ID Number

text(id[i],x+ i+30, y); //ID Number text(employeeName[i],x+ i+80, y); //Hours Worked text(hoursWorked[i],x+ i+600, y); y=y+70; } }

double pay(double hours) {

if ( hours <= 40) return hoursRATE; else return (40RATE)+((hours - 40)RATE1.5);

}

Tagged:

Answers

  • Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text

    Kf

  • edited May 2018 Answer ✓

    please also format the data as if it were code

    Employee ID Employee Name Hours Worked 1 Alabaster Snowball 40 2 Bushy Evergreen 25.5 3 Pepper Minstix 45 4 Sugarplum Mary 42

    since this is homework:

    text( pay ( hoursWorked[i] ) ,x+ i+690, y);
    
  • edited May 2018
    Employee ID Employee Name Hours Worked
    1 Alabaster Snowball 40 
    2 Bushy Evergreen 25.5 
    3 Pepper Minstix 45 
    4 Sugarplum Mary 42
    

    hm.... OR

    Employee ID, Employee Name,Hours Worked
    1,Alabaster Snowball,40 
    2,Bushy Evergreen,25.5 
    3,Pepper Minstix,45 
    4,Sugarplum Mary,42
    
Sign In or Register to comment.