I don't know how to do methods, and I need them for this Lab.
Would anyone be able to help me?
There are two different payroll files: Lab4Input1.txt and Lab4Input2.txt. Your program will only input one. You must run the program TWICE, once for each input file. Input a variable from the keyboard and use that to determine which file you will use and which output file you will create Lab4Ouput1.txt and Lab4Ouput2.txt. Verify that your input from the keyboard is valid by using do/while loop and a Boolean as a conditional. All instructions to determine which files to use must go BEFORE you open the files. Instead of using a string literal for the file name, you will use a variable.
NOTE:See Lab4File Logic in the Lab4 folder.
Calculate a bonus for anyone in the sales department (department 25). (use a nested if)
Full-time (40 or more hours) get a 10% bonus Part-time (less than 40 hours) get a 5% bonus
Write as a value-returning method
Translate department code to department name (use switch)
20 = “Administration”; 23 = “Production”; 25 = “Sales”; anything else is “Invalid Dept”
Print this in the detail line for each employee
Write as a value-returning method.
Gross pay consists of two parts: regular pay and overtime pay. (use if-then or if-then-else)
Overtime is paid at time and a half (1.5 times the hourly rate) for the hours over 40
Round to two decimals.
Regular pay is any hours, 40 or less, paid at the hourly rate.
Round to two decimals.
Add regular pay and overtime pay to get gross pay.
Write as a value-returning methods
This is what I have
//Lab #5
//File: electric.java
//Programmer: Joe Tokarczyk
import java.util.Scanner; //for scanner class
public class electric
{
public static void main(String[]args)
{
double a, //Account Number
m, //Meter Reading (Kwh)
p; //Amount Due
int n, //Number of times
c; //Counter
String d; //Customer Name
Scanner input = new Scanner(System.in); //Starts a new scanner
System.out.println("How many customers do you have?"); //Gets the number of customers to input data
n = input.nextInt();
for(c=0;c<n;c++)
{
System.out.println("What is the customer's name?");
d = input.nextLine();
System.out.println("What is the account number?");
a = input.nextDouble();
System.out.println("How many Kwh were used?");
m = input.nextDouble();
if(m<=300)
p=5;
else if(m<=1000)
p=(5+(m*.03));
else
p=(35+(m*.02));
System.out.println("The customer" + d + "with the account number" + a + "owes" + "$" + p);
}
}
}
This post was edited by Archer on Nov 26 2012 10:23am