Hello, I am a little stuck. I have grasped the concept of methods, understanding thier purpose but still unsure on how to code it. Below is part of my code I kindly need guidance on. I am trying to create a method which can hold roles and depending on which switch option is selected it will return the the amount. I have four employement roles which all have different payscales. I have commented the errors on the role method. IfI can correct this and make it work then I can complete this program :)
import java.util.Scanner;//allows input from the keyboard
import java.text.*;
class Wage_Method_2 // a class is a collection of static and non-static methods and variables/class name
{
public static void main(String[]args)//The main method; starting point of the program.
{
Scanner input = new Scanner(System.in);//declaring and creating scanner; an inputstream / start of class
DecimalFormat fmt = new DecimalFormat("0.00");
//DecimalFormat Currency = new DecimalFormat("###,###,##0.00");
double normHrs = 0, overHrs = 0, bonusHrs = 0, actualHrs = 0, cash=0, overPay =0, bonusPay = 0, grossWage = 0,vat23 = 0, netWage =0;
String empName,nextEMP = "y", manager, superVisor, teamLead, general; // declaring variables
System.out.println ("\t\t************************");
System.out.println ("\t\tHUMAN RESOURCES: PAYROLL"); // displays title of program
System.out.println ("\t\t************************");
while (nextEMP.equalsIgnoreCase("y"))// this loops around the entire program to allow the user to repeat adding in emp hours
{
System.out.print("Please enter an employee's first name: "); // name of employee
empName = input.next();//their name
System.out.print("Please enter "+empName+"'s employment ID: "); // name of employee
int job = input.nextInt();//their name
System.out.print("Please enter their total hours worked: ");// hours they have worked
actualHrs = input.nextDouble();// their hours
double basicPay = rate (5.75)*actualHrs;
System.out.println("Basic Pay: "+basicPay);
if (nextEMP.equalsIgnoreCase("n")) // if "n" is entered...
{
System.out.println("Thank you, the hours have been successfully logged.");// polite exit message
}
}// end of whileloop
}// end of class
public static double rate (double cash String jobrole)// when compiling these errors appear: error: ')' expected and error: <identifier> expected
{
switch (jobrole)
{
case 1:
cash = 5.75;
case 2:
cash = 5.75*1.1;
case 3:
cash = 5.75*1.25;
case 4:
cash = 5.75*1.42;
break;
}
return (cash);
}
}// end of program