d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Help With Methods
Add Reply New Topic New Poll
Member
Posts: 24,488
Joined: Aug 5 2008
Gold: 38.00
Nov 26 2012 10:23am
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
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Nov 26 2012 01:12pm
maybe you should start by reviewing class notes, lecture slides, and any textbook reading you were assigned
Member
Posts: 24,488
Joined: Aug 5 2008
Gold: 38.00
Nov 26 2012 06:14pm
Quote (irimi @ Nov 26 2012 02:12pm)
maybe you should start by reviewing class notes, lecture slides, and any textbook reading you were assigned


book was stolen and i was absent on the day of the methods during the online lecture. its an online class
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 26 2012 06:23pm
Quote (Archer @ Nov 26 2012 08:14pm)
book was stolen and i was absent on the day of the methods during the online lecture. its an online class


lolwat?

http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Nov 26 2012 06:34pm
Quote (Archer @ Nov 26 2012 05:14pm)
book was stolen and i was absent on the day of the methods during the online lecture. its an online class


how convenient.

get a new book.

This post was edited by irimi on Nov 26 2012 06:34pm
Member
Posts: 827
Joined: Jan 16 2012
Gold: 0.00
Warn: 10%
Nov 27 2012 01:23pm
Quote (Archer @ Nov 26 2012 10:14pm)
book was stolen and i was absent on the day of the methods during the online lecture. its an online class


how convenient².

Fucking google.
Member
Posts: 16,218
Joined: Sep 27 2009
Gold: 13.00
Nov 29 2012 04:00pm
Lol man, your work is half done, just read what you have write for us, and u'll find ur methods ... And btw, I think u didn't understand what is really required (i'm not talking about the methods, but about the subject in general)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll