If Statement - Overtime Hours
Feb 24, 2015
why my code isn't working. I have to make it so that any time over 40 hours results in time and a half (1.5). Whenever I run the code, it makes it as if EVERY hour is time and a half when it shouldn't be.
import java.util.*;
public class lab3
{
public static void main(String []args)
{
double grosspay, pay, hours, federal, fica, state, totaltaxes, netpay;
Scanner input=new Scanner(System.in);
System.out.println("");
System.out.print("Enter Your Hours Worked: ");
hours=input.nextDouble();
System.out.print("Enter Your Pay Rate: ");
pay=input.nextDouble();
[code]....
View Replies
ADVERTISEMENT
Sep 12, 2014
The pay rate is php 35.00 per hour. any hours worked after 40 hours is paid at rate of 2 times the normal hourly rate. Calculate and display the Normal Pay, The overtime pay, and the total pay.
OUTPUT MUST BE:
Sample 1 :
Enter Hours Worked: 40 (Sample)
Normal Pay: 1400 (Sample)
Overtime Pay: 0 (Sample)
Total Pay: 1400 (Sample)
Sample 2 :
Enter Hours Worked: 41 (Sample)
Normal Pay: 1400 (Sample)
Overtime Pay: 70 (Sample)
Total Pay: 1470 (Sample)
Here is my code or something, but i cant finish it.
import java.util.Scanner;
public class Workpay {
public static void main(String[]args) {
Scanner in = new Scanner (System.in);
int hours;
int normalpay = 35;
[Code] .....
View Replies
View Related
Oct 16, 2014
Having just started college, Bob has been busy looking for a part-time job to fund his new college social life and after only two weeks of looking he has managed to get two job offers! Each job comes with different hours, basic rates of pay and over-time rates so he needs to work out which would get him the most money.
Develop an application that would allow Bob to enter his basic pay rate, his number of regular hours work per week and his number of overtime hours per week. The application should then calculate and display Bobs total basic pay for the week, his overtime pay for the week and his total pay including overtime.
Your application should use instantiable classes to separate the calculations from the user input and output.
Save the instantiable class as Pay.java
Note: The overtime rate is 1.5 times the basic rate of pay
This is my instantiable class code which compiles correctly
public class Pay{
//Declare Data members/Variables
private double pay;
private double hours;
private double overtime;
private double totalBasicPay;
[Code] .....
My errors in the second bit of code that i have never seen before
"C:UsersAndreDownloadsPayApp.java:25: error: no suitable method found for println(<null>,String)
System.out.println(null,"Please enter Basic Pay");
^
method PrintStream.println() is not applicable
(actual and formal argument lists differ in length)
[Code] .....
View Replies
View Related
Dec 9, 2014
is there away to list all hours between two dates?
For example if i have 12/7/2014 21:03:56 and 12/8/2014 04:40:45 I need an output, i can write to a file: (the dates are currently in String variables)
12/7/2014 21:00
12/7/2014 22:00
12/7/2014 23:00
12/8/2014 00:00
View Replies
View Related
Oct 7, 2014
Basically I need to increase the hours of an employee at the given index. Index is the position of the employee in the array, and amount is how many hours you will be increasing by.
This is what I have so far,
public void increaseHours(int index, double amount){
for(Employee e: employees){
if(e instanceof HourlyEmployee){
HourlyEmployee he = (HourlyEmployee)e
he.increaseHours(amount);
}
}
}
}
I'm not sure how to use the index to do this correctly, all it's doing right now is adding hours to every hourly employee
View Replies
View Related
Oct 7, 2014
Basically I need to increase the hours of an employee at the given index.Index is the position of the employee in the array, and amount is how many hours you will be increasing by.
This is what I have so far,
public void increaseHours(int index, double amount){
for(Employee e: employees){
if(e instanceof HourlyEmployee){
HourlyEmployee he = (HourlyEmployee)e
he.increaseHours(amount);
}
}
}
}
View Replies
View Related
May 13, 2014
I am really struggling to make the Split String method work with another method which is double hours.
HtmlElement span = new HtmlElement(SPAN_OPEN, SPAN_CLOSE);
span.setValue("Drive Time: ");
td.addNestedElement(span);
HtmlElement span2 = new HtmlElement(SPAN_OPEN, SPAN_CLOSE);
span2.addAttribute("class", "drive_time");
String time=String.valueOf(showSet.getTransferHours());
/*Split the Strings into Hours and Minutes*/
[code]...
View Replies
View Related
Jun 19, 2014
So from what iv learnt in Java and programming in general is that using a case statement is far more efficient that using multiple IF statements. I have an multiple IF statements contained within a method of my program, and would like to instead use a case statement.
public String checkPasswordStrength(String passw) {
int strengthCount=0;
String strengthWord = "";
String[] partialRegexChecks = { ".*[a-z]+.*", // lower
".*[A-Z]+.*", // upper
".*[d]+.*", // digits
".*[@#$%!]+.*" // symbols
[code].....
View Replies
View Related
Aug 13, 2014
import java.io.*;
public class workhours{
public static void main (String args[]){
try{
BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
String days[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
[Code] .....
View Replies
View Related
Apr 27, 2013
I want to compare two times. What I am doing is
java.util.Date date = new java.util.Date();
java.sql.Time cur_time = new java.sql.Time(date.getTime());
/*this is my database connectivity code from where I am getting second date that I am comparing. This is right. Don't bother it.
Connection c= ConnectionManager.getConnection();
String sql = "select t from datesheet where subjectCode=? and sessional=? and d=?";
PreparedStatement ps = c.prepareStatement(sql);
ps.setString(1,subjectCode);
ps.setString(2,sessional);
ps.setDate(3,cur_date);
ResultSet rs = ps.executeQuery();*/
if(rs.next())
{
java.sql.Time t = rs.getTime("t");
long diff = cur_time.getTime()-t.getTime();
}
Then I am converting it to seconds, minutes and hours, but the problem is time that we get from cur_time.getTime() has more digits than time that we get from t.getTime(), so it is always greater than t.getTime() even when it is not.
long seconds = (diff/1000)%60;
long minutes = (diff/60000)%60;
long hours = (diff/(60*60*1000))%24;
View Replies
View Related
Oct 3, 2014
So I need to make a for loop for this problem: A certain type of bacteria doubles its population every twelve hours. If you start with a population of 1000, how many hours will it take for the population to exceed 1,000,000? Output needs to be in table format, such as:
Hours: - Population:
0 ------- 1000
12 ----- 2000
24 ----- 4000
I've created the code, but don't understand how to increment hours by 12 and double the population by 2 each time.
public class Population
{
public static void main (String[] args) {
int hours = 0;
int population;
[Code] ....
View Replies
View Related
May 13, 2014
I have an application which is doing a fine job of placing the total hours on the interface.
Where I am breaking down is that I am unable to split the string into two distinct groups: hours and minutes
private HtmlElement createTravelTimeRow(ShowSet showSet) {
HtmlElement tr = new HtmlElement(ROW_OPEN, ROW_CLOSE);
HtmlElement td = new HtmlElement(CELL_OPEN, CELL_CLOSE);
[Code].....
I came across something which showed how to split the String but I am still very unsure how to do this.
View Replies
View Related
Feb 28, 2014
I think I fixed the first error, but now I'm receiving another error in my Net Pay print statement at the end.
Here is what I'm supposed to receive:
Net Pay: 599.86
Here is my sample run:
run-single:
Enter hourly rate in dollars and cents --> 27.16
Enter number of hours and tenths worked --> 37.9
PAYROLL REPORT
Rate: 27.16
Hours: 37.9
Gross Pay: 1029.36
Federal Tax: 257.34
State Tax: 93.41
FICA: 78.75
Net Pay: 771.86
Employer's FICA contribution: 78.75
Employer's UEI and DI contribution: 20.59
Cost to Employer: 1128.70
Enter hourly rate in dollars and cents -->
Here is my updated code:
package assignmentproject1;
/* CHANGE (FINAL) VAR NAMES, SCAN & VERIFY,
ORGANIZE AND PUT FORMULAS ON BOTTOM, ORGANIZE VAR @ TOP, */
import java.util.*;
public class Project1 {
public static void main (String[] args)
[Code] ....
View Replies
View Related
Mar 14, 2014
Write a java program that calculate the grade point of three subjects and their credit hours through if the grade points and the credit hours are
Subject---grade---gradepoint-----credit hours
Maths------A--------4.0---------3
English composition-----B-------3.0-----2
French-----B+ ---- 3.3----------3
Now,if the grade point is equal to 4 ,print out First class
If the grade point is equal or greater than 3.0 but less than 4,print out Second class upper
If the grade point is equal or greater than 2.0 but less than 3,print out second class lower
Use the if-else-if statement
View Replies
View Related
Feb 22, 2014
Here is what im trying to do
Write a class that accepts a user's hourly rate of pay and the number of hours worked. Display the user's gross pay (gross pay = hours worked * hourly rate), the tax withheld (tax withheld = gross pay * tax rate) and the net pay (net pay = gross pay - tax withheld).Use a named constant for storing the tax rate of 0.15
Here is my Code:
import java.util.Scanner;
class Tutorial
{
public static void main(String[] args);
[Code]....
View Replies
View Related
Nov 18, 2014
So I want to make a simple Java that ask the user to pick a powers and it has two options.If the user picks magic then execute the first if statement then ask the user again which type of magic the user wants.I can't make it work it keeps printing the else statement. Why is that?
import java.util.Scanner;
public class Variable {
static Scanner zcan = new Scanner(System.in);
public static void main(String[] args)
[code]....
View Replies
View Related
Jul 29, 2014
I am trying to run a class with a client code and I get the following error
The method add(TimeSpan) is undefined for the type TEST
Why i get this error?
package timespan;
// Represents a time span of hours and minutes elapsed.
// Class invariant: minutes < 60
public class TimeSpan {
private int hours;
private int minutes;
[Code] ....
View Replies
View Related
Sep 19, 2014
I'm fairly new to JSTL. Can I convert the minutes JSTL expression into hours and minutes using a java method. I'm not sure how to go about.
<% CalendarUtilities.getHoursAndMinutes(%> ${minutes} <% ) %>
View Replies
View Related
Apr 5, 2014
I'm trying to run an if statement with an input condition and here is my code.
import java.util.Scanner;
public class App10A {
public static void main(String[] args) {
Scanner fun = new Scanner(System.in);
System.out.println("What's your name?");
String name = fun.nextLine();
[code]....
When the computer asked me "What's your name?", I typed in Victor, then the result turned out to be "Oops, try again!".I typed in Victor (without parenthesis) and "Victor" and both gave me the negative results.What exactly should I put in in order to get "This is the result I wanted!" ? how should I modify my code in order to get "This is the result I wanted!" when I put in Victor (without changing the equal sign)?
View Replies
View Related
Feb 17, 2014
How do I use a variable in an if statement to return a public void method from another class? I've tried:
System.out.print("select 1 - 6: ");
Scanner myScanner = new Scanner(System.in);
myScanner.nextInt();
if (myScanner.nextInt()==1) {
carSelection colour = new carSelection();
colour.carSelection();
The method colour in class car selection is just 4 print line statements? I've // out the if statement to see if it is correctly calling the method and displaying the data and it is?
View Replies
View Related
May 5, 2014
I'm having a problem where an if statement isn't working. In the Person class boolean olderThan ignores my if statement so it always returns false and I just don't get why that's happening.
import java.util.Calendar;
public class Person {
private String name;
private MyDate birthday;
public Person(String name, int pp, int kk, int vv) {
this.name = name;
[code].....
View Replies
View Related
Jan 28, 2015
In the program below I populated three arrays: student id, name, and GPA. The findStudent() method attempts to match users input with the input stored in the studentID array using an if/ else statement. When I use the if/ else statement the else always executes regardless if the IDs match? I am trying to get JOptionPane.showMessageDialog(null, "Incorrect entry"); to print only if the IDs don't match.
Java Code:
//FILE: StudentIDArray.java
import javax.swing.*; //Used for the JOption dialog boxes
import java.util.*; //Used for Scanner input
public class StudentIDArray {
boolean nameFound = true;
final int numOfElements = 2; //Final int to control to loop for data
[code]....
View Replies
View Related
Nov 21, 2014
i'm confused about the if statement part because int i = 0 is set to zero but how can you get the remainder if int i is zero?
for (int i = 0; i < 200; i++) {
if (i % 12 == 0) {
System.out.println("#: " + i);
}
explain to why it output like this?
#: 0
#: 12
#: 24
#: 36
#: 48
#: 60
#: 72
#: 84
#: 96
#: 108
#: 120
#: 132
#: 144
#: 156
#: 168
#: 180
#: 192
View Replies
View Related
Mar 20, 2014
My program basically has 2 executeQuery statements. Based on the result of the first sql query the 2nd sql query gets executed (I intend to use if else ladder). The control executes the first query but never executes the second one.
MY CODE:-
//package searchbook;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
[code]....
View Replies
View Related
Mar 1, 2015
I have this JAVA written but I can't get the parameters for the if statements right.
import java.util.Scanner;
public class myFirstJAVA {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Please enter command: ");
String text = input.nextLine();
[Code] ....
View Replies
View Related
May 1, 2015
I am making a simple calculator. I want the user to input either string "add" or "subtract" and then it will take two numbers and either add or subtract them. I cannot get the if statement to work with a string!
import java.util.Scanner;
public class newcalc {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter add or subtract");
String line = input.nextLine();
if input = "add";
View Replies
View Related