Payroll Code - If Input Hours Greater Than 40 Cost To Employer Calculation Goes Wrong

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


ADVERTISEMENT

Java Fraction Calculation Compiles But Output Is Wrong

May 9, 2014

So all the errors in the code is fixed but its now got the wrong output

what I get:

Enter numerator; then denominator.
5
8
5/8
Enter numerator; then denominator.
4
10
4/10
Sum:0/0

it should be:

Enter numerator; then denominator.
5
8
5/8
Enter numerator; then denominator.
4
10
4/10
Sum: 82/80 1.025
Product: 20/80 0.25
Enter numerator; then denominator.
6 0
infinity

here is the code

Fraction.java
public class Fraction { //declares that it's a class that can be intantiated
private int numer; // private intager for numerator
private int denom; // private intager for denominator

[Code] ....

View Replies View Related

Prompt User For Input Number And Check If It Is Greater Than Zero - Java Multiplication

Apr 13, 2014

Write a program that prompts the user for an input number and checks to see if that input number is greater than zero. If the input number is greater than 0, the program does a multiplication of all the numbers up to the input number starting with the input number. For example if the user inputs the number 9, then the program displays the following sum:

9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 362880

That's the question I'm getting and so far all I've got is

import java.util.Scanner;
public class Lab4Q3
{
public static void main (String[] args)
{
int keyboard;

[Code] .....

View Replies View Related

Display Two Types Of Table One With Initial Cost And Another With New Cost

Mar 16, 2015

HTML Code:

import java.util.Scanner;
public class BellmanFord {
private int distances[];
private int numberofvertices;
public static final int MAX_VALUE = 999;

[Code] ....

I am trying to display two types of table one with initial cost and another one with new cost. Based on the java code here i already have one table but don't know how to display another table.

Attached is the sample output that i am aiming for. The output table for the above code is:

Enter the number of vertices
6

Enter the adjacency matrix
0 4 0 0 -1 0
0 0 -1 0 -2 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 -5 0 3
0 0 0 0 0 0

Enter the source vertex
1

distance of source 1 to 1 is 0
distance of source 1 to 2 is 4
distance of source 1 to 3 is 3
distance of source 1 to 4 is -6
distance of source 1 to 5 is -1
distance of source 1 to 6 is 2

View Replies View Related

Get Input From User To Be Multiplied By Package Cost - Discounted Total?

May 12, 2014

I am new to java and this is one of my first program assignments. I can't figure out how to make the if else statements work. I am trying to get the input from the user to be multiplied by the package cost but it gives me an error. I also can't figure out how to solve for the discounted total.

Purpose of the program: To write a program that asks the user to enter the number of packages purchased. The program should then display the amount without any discount, the amount of the calculated discount (if any), and the total amount of the purchase after the discount is applied.

What the output should be:

Enter the number of packages purchased: 10
Your total without discount: $990.00
The discount is: $198.00
The discounted total: $792.00

import java.util.Scanner;
public class Practice {
public static void main(String[] args) {
double packageCost = 99.00;
double amtPackage = 10.00;
double withoutDiscount = packageCost * (double) amtPackage;

[Code] .....

View Replies View Related

Receiving Wrong Minimum Value And Code Is Not Reading File Properly

Feb 11, 2015

My program is reading my file, but its printing out weird cryptic numbers instead of the 1-10 that is in the file. But it uses the numbers in the file to get the Max Value and Total. Also I am receiving 0 for my Minimum Value but, 0 isn't even in the file, my lowest value is 1.

Java Code: /*

* Student Name: Irrelavent
*
* Description: This program will read from a text file and display its contents in an array format as well as the average of the numbers and the minimum and maximum value within the array and it will display the total of all the numbers added together.
*
* Input Variables:
*
* Desired Output:
* Total: 55
Average: 5.5
Minimum Value: 1.0
Maximum Value: 10.0
The data being used is: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
*/

[Code] ....

Output:

Numbers being used: [[I@55f96302]

---------------
Max Value: 10
---------------
Minimum Value: 0
---------------
Average: 0.0
---------------
Total: 55

I want 1 for my Minimum and I want 5.5 for my average, when I make 'average = total / numbers.length;' ---> 'average = total / (double)numbers.length;' I get 0.55. Also, as its obvious, my 'Numbers being used' section is messed up and I don't know whats causing this.

View Replies View Related

How To Get Calculation To Work Using User Input From Textfields

Feb 23, 2014

As stated in the subject I'm a newbie when it comes to Java Programming (I'm in my second week of class). I'm trying to create a Retail Calculator for a class and need to multiply two values together (Price, Discount) in order to get the sale's price when the user hits a Calculate button. The price and discount are user input values from textfields in the beginning of the code.

public void actionPerformed(ActionEvent e) {
String price;
String discount;
float salePrice;
//Get the original price from price textfield
price = priceValueField.getText();

[Code] ....

View Replies View Related

Age Calculation Based On Input (Date Of Birth)

Nov 9, 2014

I am trying to solve this problem but it is not working properly, when i enter the date of birth, such as 1993 12 14 it comes up as 21 years old instead of 20.

import java.util.*;
class Age
{
public static void main( String [] args)
{
Calendar rightNow = Calendar.getInstance();
 
[Code] ....

View Replies View Related

Guess Number Game - Reveals Answer If User Input Is Wrong

Sep 1, 2014

The problem occurs after the user inputs the guess.... it either runs the for loop if guess = numtoguess and reveals the answer even if the user input is wrong.... or it always runs the first if statement in the while loop if guess!= to numtoguess... heres the code

public static void main(String[] args) {
String[] Answers = {"yes", "Yes", "No", "no"};
String Name = JOptionPane.showInputDialog(null, "Hello, What is your name?","Random Game", JOptionPane.QUESTION_MESSAGE);
String UI = JOptionPane.showInputDialog(null, Name + " do you want to play a game", "Random Game", JOptionPane.QUESTION_MESSAGE);

[Code] ....

View Replies View Related

Temperature Conversion Project - Send Input Value To Calculation Area And Get Value To Display In JLabel

Sep 30, 2014

The problem I'm trying to resolve now is getting my ActionEvent to send the value input in the JTextArea out to be calculated, then to display the result in my result JLabel.

Here is an image of the GUI :

The basic procedure the teacher is asking for is the user is supposed to enter a temperature in the input. The user then clicks the input scale, and then on the output scale selection the converted value is to be displayed in the output area.

As I mentioned my problem is in the sending of the input value to my calculation area, and getting the value to display in the JLabel.

How should I approach this solution? Do I need to have a listener after the JTextArea of the input box? Will that allow me to limit the input values to numbers only?

final JTextArea inputText = new JTextArea("" + (char)176,1,4);
//ReadConsole equivalent to specific input was a number?

Here is the section of code my ActionListener is:

//celOut represents the Celcius output scale JRadioButton.
celOut.addActionListener (new ActionListener () {

@Override
public void actionPerformed(ActionEvent e) {
//if the Celcius Input Scale is selected.
if(cel.isSelected())

[Code] ....

All the calculations are required to occur in a separate java file, which what I think is tripping me up. How do I send a value from the JTextArea into the Calc.celToFahr method?

//contents of my Calc.java calculation class.
public class Calc {
public static double celToFahr(double cel){
return cel * (9./5.) + 32.;
}
public static double fahrToCel(double fahr){
return (fahr - 32.)*(5./9.);
}
}

View Replies View Related

Input Color Code In HSV And Output Equivalent RGB Code

Oct 9, 2014

I need to create a Java program that takes an input a color code in HSV and outputs the equivalent RGB code and Vice versa.

Example:
If you test on the color RED in RGB:
Input: (255,0,0)
Output: (0,100%,100%)
If you test on the color RED in HSV:
Input0,100%,100%)
Output: (255,0,0)

View Replies View Related

Generate QR Code From Input Text And Display Information About Input / Output Bits

Nov 12, 2014

I am trying to write a program that will generate a QR Code from an input text and also display some information about the input/output bits. So far I have created the frame and what to do next. And I'm not sure if I am on the right track since my level of programming is not that great. By the way, I am using zxing libraries from GitHub. I know, there are plenty of generators online for the QR Code, but that is not what I am looking for. As you can see on the attached image, I am more interested in the efficiency of encoding 2D data. Also, I noticed that almost all the online projects regarding 2D codes are for Android. Which is not very useful.

// QR Code Generator
package qrcode;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

[Code]....

View Replies View Related

Create Payroll Program

Jun 14, 2014

I am now at the beginning trying to teach myself Java :) So far it has been good everything however now I came across the problem where I wanted to create payroll program for myslef based on one of the books I have.Somehow the issue in provided program code gives me the negative values on the salaryNett and valueTax:

Java Code:

import javax.swing.JOptionPane
public class FinnancialApplicationPayroll {
public static void main (String[] args){
String input = JOptionPane.showInputDialog (null, " What is your name");

[code]....

View Replies View Related

Payroll Class - Displaying Gross Pay?

Jan 25, 2015

I am having trouble with this displaying the grosspay. Why it is not displaying it right. All I am getting is 0.00 all the time, everything else seems to work great.

// This program shows the payroll coding challenge

public class PayRoll
{
// Constant for the number of employees
public final int NUM_EMPLOYEES = 7;
private double[] employeeID = {5658845, 4520124, 7895122,
8777541, 8451277, 1302850,
7580489};
// To hold hours worked
private int[] hours = new int[NUM_EMPLOYEES];

[Code] ....

View Replies View Related

Write A Payroll Class That Uses Arrays As Fields

Apr 26, 2015

I have an assignment to write a Payroll class that uses the following arrays as fields:

-employeeID - An array of seven integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489
-hours - An array of seven integers to hold the number of hours worked by each employee
-payRate - An array of seven doubles to hold each employees hourly pay rate
-wages - An array of seven doubles to hold each employees gross wages

The class should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the number of hours worked by the employee whose identification number is stored in element 0 of the employeeID array. That same employee's pay rate should be stored in element 0 of the payRate array. In addition to the appropriate accessor and mutator methods, the class should have a method that accepts an employee's identification number as an argument and returns the gross pay for that employee. Demonstrate the class in a complete program that displays each employee number and asks the user to enter that employee's hours and pay rate. It should then display each employee's identification number and gross wages. Input Validation: Do not accept negative values for hours or numbers less than 6.00 for pay rate.

I'm off to a great start, however I'm stumped on how to pass the payrate for each employee into the array, then grab that data in order to calculate the gross wage for each employee and store THAT in its own array. THEN I'll have to output that data to each employee.

Code is shown below.

import java.util.Scanner;
import java.text.DecimalFormat;
public class PayrollProgram {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("0.00");

[code]....

View Replies View Related

Generate RetroActive Salary Case In Payroll Generation

Jan 23, 2014

I am having a doubt about how to fix and what could be the code to generate a retroActive salary case in payroll generation. Upto last year(2013) it was working fine.Now it is 2014 and i am stuck as i am new to java.

The system is computing every value in yearly basis,but the inputs are in monthly basis.

View Replies View Related

How To Input Exit Code Into Program

Mar 12, 2014

I just want to know how I can get my program to end when the user inputs "0." By using: System.exit(0);

import java.util.Scanner;  
public class TestCode
{
public static void main (String [ ]args ) {
Scanner console =new Scanner(System.in);
System.out.println("To exit program input 0");
for (int y = 1; y < 11; y++ ){ // Executes output 10 times
 
[code]....

View Replies View Related

Can't Override A Method - It Still Ask For Level 1.5 Or Greater

Apr 29, 2014

I'm using "standard-kepler-SR2-win32-x86_64" and have installed "jdk-8u5-windows-x64".

But eventhough I can't override a methode like that "@override", it still says me:"annotations are only available, if source lever is 1.5 or greater".

Fine, therefore I installad "jdk-8u5-windows-x64", its the higest one on that oracle side, what else is needed?

View Replies View Related

If Statements - Each Number Entered In Greater Than Zero

May 9, 2014

write a program that will ask the user to enter five numbers.using If statements if each number entered in greater than zero

import.java.util.Scanner;
public class Java3 {
public static void main(String[] args) {
function addNumbers(n1, n2, n3, n4, n5){
var finalNumber = 0;

[Code] ....

addNumbers(1, 2, 3, 4, 5,);

View Replies View Related

How Many Numbers In Array Have Value Greater Than Or Equal To 100

Sep 10, 2014

I have an assignment that wants me to write a Java function based on induction to determine how many numbers in an array have a value greater than, or equal to, 100.

I have started with:

Java Code:

int recurseHundred (int [] A, int n) {
//n is the number of elements in the array.
//Base case:
if (n == 1 && n >= 100) return A[0];
//Recurse
int num = recurseHundred(A, n-1);
if (n-1 >= 100) return A[n-1];
else return num;
} mh_sh_highlight_all('java');

I don't think this actually does the trick.

View Replies View Related

Array - How To Iterate Through Only Values Greater Than 0

Feb 9, 2014

I have an 46x9 array. I only have 108 values in the array for which I need to perform preliminary computations. How do I get the read to only read the 108 values whose values are greater than 0 and skip the other 495 whose values are 0?

View Replies View Related

Payroll System For Hourly / Fixed Monthly And Commission Paid Workers Of Company

Dec 21, 2014

I am doing a program where i have to implement a payroll system into a company for hourly, fixed monthly and commission paid workers. I also have to put the method which i did. the problem is I cant tell if my calculation is wrong or if i am missing a codes some where. The output is not giving me the answer that I was at least expected,

Here is my method:

{
< double total_deduction;>
< total_deduction = gross_pay - deduction;>
< return total_deduction;>
}
< public static double calGrossH(double hours_worked, double pay_rate)>

[Code] .....

I have done a lot researching and have come up with some search with almost the same calculation and I have also asked employees of a company on how they calculated hourly rate, commissions rate and fixed rate for all workers and gotten the same response but for some reason the output is not what it is supposed to output. here is my output.

<
un:>
<please enter the number of employees to be processed 31>
<please enter employee id number 3669>
<please enter employee first name>

[Code] ....

I dont know if I am missing some calculation somewhere or codes been researching and bussing my brains to figure out where is the missing codes or calculation.

View Replies View Related

How To Read Input Of Source Code With FileReader

Oct 19, 2014

I'm doing homework and as far as input, my assignment reads: "Your program must take as input the name of a Java source code file such as the source file containing the source code of this assignment." So my question is, how do i do that without linking the directory directly (i.e. C:/users/...)? I'm using FileReader as shown below...

public static void main(String[] args) throws Exception {
FileReader file = new FileReader (WHAT GOES HERE???);
BufferedReader reader = new BufferedReader(file);
String s = "";
String line = reader.readLine();
 
[Code] .....

View Replies View Related

Java Code That Ask User For Password Input

Jul 21, 2014

This is the java code that I wrote for a password:

// java application that asks the user to enter a password
 import java.util.Scanner; //program uses class scanner
 public class password{
//main method used to execute java application
public static void main(String args[]){
//create scanner to obtain input from command window

[Code] ....

here is the output of the code when I run it :

entered the passwordreason
Try againPress any key to continue . . .

The code compiles without errors. The problem is when , I entered the actually password that I declared in my code, it doesn't output "You entered the correct password" but it instead outputs "Try again", which is supposed to be the output if you've entered the incorrect password. What did I do wrong?

View Replies View Related

Find Number Of And Sum Of All Integers Greater Than 100 And Less Than 200 Divisible By 7

Oct 30, 2014

 Write a program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7.

View Replies View Related

Code Storing Input Data In All Three Of Product Objects?

May 7, 2014

My problem is that in my program, I have the user input data for one of three product objects, however when I read the data for all three objects, the same data is stored in all of them.

Anyway this is the method from the Interface class:

private void readInput() // the only method in the program that accepts product data from the user {
Store matesStore = new Store();
String name;
int demandRate, productChoice;
double setupCost, unitCost, inventoryCost, sellingPrice;
Scanner console = new Scanner(System.in);

[Code] ....

And here is the method from the Store class:

public static void addData(int option, String newName, int newDemand, double newSetup, double newUnit, double newInventory, double newPrice)
//sets the product data for a particular product {
if (option==1) setData(product1, newName, newDemand, newSetup, newUnit, newInventory, newPrice);
else if (option==2) setData(product2, newName, newDemand, newSetup, newUnit, newInventory, newPrice);
else /*(option==3)*/ setData(product3, newName, newDemand, newSetup, newUnit, newInventory, newPrice);

[Code] ....

The problem I had was with static variables and methods.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved