Tax Calculation Program

Apr 9, 2014

use arrays to store taxpayer information. Use methods for tasks that will be repeated.

-Ask the user how many taxpayers he would like to calculate taxes for.
-Ask the user to enter each taxpayer's first name, last name gross income, and number of children.
-Each taxpayer's tax due is computed as follows
-The taxpayer's dependency exemption is determined by multiplying $3,000 times the number of children.
-The taxpayer's net income is determined by taking the taxpayer's gross income and subtracting the taxpayer's dependency exemption.
-If the taxpayer's net income is between 0 and 50,000, the tax due is 15% of net income.
-If the taxpayer's net income is greater than 50,000, the tax due is
-15% of the first 50,000 of net income PLUS
-25% of any income over 50,000
-The tax due can never be less than 0.
-If the net income is a negative number, the tax due is 0

TAXPAYER INFORMATION: output a message in one dialog box which lists the following info for every taxpayer: first name, last name, gross income, number of children, tax due.
AVERAGE TAX: output a message in a dialog box which states the average of the taxes due.
PRESIDENTAL MESSAGE: output a message in a dialog box which says either "We computed taxes for the president. " or "We did not compute taxes for the president." The president's name is Barack Obama.

Here is my code so far

import javax.swing.JOptionPane;
public class AssignmentSeven
{
public static void main (String [] args)
{
String [] taxPayers;
String[] firstName;
String [] lastName;
String message = "";
double[] grossIncome;

[code]....

View Replies


ADVERTISEMENT

Writing A Calculation For A Program?

Sep 8, 2014

I am writing a program in Java where a user adds 1 stamp on a letter for every five sheets of paper in it (or fraction thereof)For example, I if I have 11 sheets of paper, I add 3 stamps. If the total number of stamps is more than 3, they don't send it.

I need to ask the user how many sheets of paper they have, and then calculate the appropriate number of stamps based on the formula above. I just don't know how to write the math formula to calculate this, i'm stuck. So far I have:

package test;
import java.util.Scanner;
public class LetterMailing {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int numSheets;

[Code] .....

What should I do next?

View Replies View Related

Different Units In Calculation

Sep 8, 2014

I have a maths application I am working on in java. This is more related to maths but there could be some here who have worked with calculations like this in their java project.

One could convert from degree to radians and from mph to knots. Could one convert from knots to degree or from mph to degree?

View Replies View Related

Calculation In Awt Calculator

Jul 10, 2014

I am facing problem during calculation in my awt calculator. It is showing NumberFormatException. Below is part of code.

if(e.getSource()==b14)//On button 14, label is "/"
{
String v1=tf.getText().toString();
num1=num1+Integer.parseInt(v1);//num1 is as integer variable
tf.setText("");//tf means textField
}else

[code]....

View Replies View Related

Java GUI Calculation

Oct 3, 2014

how to do this last calculation. I want the user to input and odometer (in feet) and have it use that and the Duration (in hours) to calculate speed in feet per second. Ive been trying to reference it using various methods but I'm stuck. I have it set as a string but whenever i try to pretty much use somewhat the same formula i did for total time it just gives me errors. How do I use that number the user inputs into a formula with the output of the Duration?

* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

[code]....

View Replies View Related

Netbeans - Calculation In GUI Interface

May 12, 2014

I'm trying to create a GUI interface in Netbeans that calculates a phone bill.

I created a GUI interface that input:
- Account Name.
- Account Number.
- Number of Minutes the phone was used. (with a textarea so the user input the minutes)
- 2 JRadioButtoms so the user can chose the regular or premium service.
- Amount Due (+10% taxes) (also with a textarea)
- Clear/Enter/Result/Done Buttoms

And I need to output:
- Account Name.
- Account Number.
- Number of Minutes.
- Taxes
- Total Amount Due.

I have a couple of math formulas I have to add them to output the above however I'm new to java so I don't know which code to use.

The math formulas are:
-Regular charges = 20 + ( No. Minutes - 50 ) * 0.20
-Premium charges = 50 + ( No. Minutes - 75 ) * 0.50
-Taxes = ( Regular charges + Premium charges ) * 0.10
-Amount Due = Regular charges + Premium charges + Taxes

View Replies View Related

Efficient GCD Calculation And Long For Loops

Jan 23, 2014

My GCD testing:

Java Code:

public static long gcd(long a, long b) {
if(b == 0) {
return a;
} else {
return gcd(b, a % b);
}
} mh_sh_highlight_all('java');

Is there a more efficient way? Also, what can I do to speed this forloop up?

Java Code:

for(long i = 1; i < 750000; i++) { dothis; } mh_sh_highlight_all('java');

View Replies View Related

Calculation - Sorting Books By Rating

Jun 19, 2014

I have a calculation that sorts books by rating...

System.out.println("
" + "
Sorted by Rating
");
  for (int count = 0; count < bookL.size(); count++) {
for (int in = 0; in < bookList.size() - 1; in++)
if (videoList.get(in).getRating() < bookList.get(in + 1).getRating()) {

[Code] ....

What am I missing here? Why doesn't this work?

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

String To A Double In Scanner - Performing Calculation?

Apr 23, 2015

This may be a multipart question. Basically I have to write a program that accepts a string, converts it to a double splits it and then performs a calculation.

public static void main(String[] args) {
String input = ""; // initalize the string
boolean isOn = true; // used for the while loop...when false, the program will exit.
String exitCommand = "Exit"; // exit command
String[] token = input.split(("(?<=[-+*/])|(?=[-+*/])"));

[Code] ....

This is the error I get:

Enter a math problemException in thread "main" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:1842)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecim al.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at Calculator.main(Calculator.java:22)

[Code] .....

How do I go about actually fixing it. Without that line commented out I get this:

Enter a math problem
2+2 <-What I entered
[Ljava.lang.String;@135fbaa4

Also, how would I go about using the submethods to check for valid operands and operators (also part of the problem) I have the actual lists made obviously, but am unsure how to get those to work with the problem.

View Replies View Related

Converting Double Values (0.0-110.0) To A 4.0 Scale (as Used In GPA Calculation)

Sep 3, 2014

I am new to programming, but am working on a program that takes 6 inputted grade averages on a scale of 0.0 - 100.0 (exceptions in the case someone has exceeded the traditional 100.0 limit) and then divides it by 6 and returns the value in a dialog box. However, I want to take the values inputted and convert them to a 4.0 scale (90.0-100.0 = 4.0, 80.0-89.99 = 3.0, etc.) and then get the average of that so that I can return an average on a 4.0 scale. I have been trying to accomplish. Also, as of right now my program only prompts the user for 6 inputs, but I'd like the user to be able to input as many as he/she would like to, I am pasting the code I currently have below.

import javax.swing.JOptionPane;
public class GPA_Calculation1_0 {
public static void main(String[] args) {
String courseOne = JOptionPane.showInputDialog("Enter numeric GPA of Course One: ");//Course one
double numOne = Double.parseDouble(courseOne);

[Code] ....

View Replies View Related

Passing Variable From Class A To B To Do Calculation But Getting Error?

Mar 23, 2015

I'm getting this error, I definitely know that is my error trying to pass method/variable because when I commented received part of my code it ran and worked.

I get this error

at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Here are my 2 classes

Java Code:

import java.awt.BorderLayout;
import java.awt.Checkbox;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[Code] .....

View Replies View Related

Make Session Attribute To Store New Value After Calculation?

Dec 29, 2014

why my session attribute for this banking webapp wont add the deposits to the session var... it just keeps going back to the amount I set it to originally - so if I set the beginning balance to 3000 then deposit 100 it becomes 3100, but if I then try deposit another amount eg. a extra 200 it becomes 3200 not 3300 like it should be !!

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.net.*;
import java.text.DecimalFormat;

[code]....

View Replies View Related

Printing Final Calculation With Correct Formatting

Oct 21, 2014

I completed this program, everything looks fine as far as calculation and stuff, but the only problem I see is that when the program wants to print the final calculation the formatting is off a little. I will add the ending result at the end of the program.

import java.util.*;
import java.text.*;
public class FutureValueApp
{
public static void main(String[] args) {

[Code] ....

Result :

Future Value Calculation

Inv/Mo.RateYearsFuture Value
[$100.00, 2.0%, 2, $2,450.64]
[$100.00, 2.0%, 2, $2,450.64]
[$100.00, 2.0%, 2, $2,450.64]
[$100.00, 2.0%, 2, $2,450.64]

Also when we have 3 different users putting their information, I get this

Future Value Calculation

Inv/Mo.RateYearsFuture Value
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]
[$100.00, 2.0%, 2, $2,450.64, $100.00, 2.0%, 3, $3,713.19, $200.00, 2.0%, 3, $7,426.38]

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

Make GUI To Calculate Orders And To Save Calculation To CSV File

Feb 1, 2014

My assignment is to make GUI to calculate orders and to save the calculation to .csv file.I have solved "save" button and it really does save my input to .csv file.But, my problem is "Load button" When I press it, how to load .csv file to my existing JTextFields?

View Replies View Related

Calculating Average Of Two Arrays - Calculation Coming Out Incorrect

Oct 8, 2014

I am working on an assignment, and I have come up with a program that runs, but it does not run correctly. This is the assignment:

Write two overloaded methods that return the average of an array with the following headers:

public static int average(int[] array)
public static double average(double[] array)

Write a test program that prompts the user to enter ten double values, invokes this method and displays the average value.

When I run it my averages are coming out incorrect, and I am not sure why. I have tried moving and rearranging things and nothing is working.

Java Code:
public static int average(int[] array) {
int sum = 0;
int average = 0;

[Code].....

View Replies View Related

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

Perform Mathematical Calculation Between Two Numbers Entered By User

Feb 16, 2015

I need to write a Java program to perform a mathematical calculation between two numbers entered by the user. User has to choose the mathematical operation and input it and then when the user enters 2 numbers, he gets the answer. When user enters any other character other than *, /, + and - he should be able to exit. Perform calculation between numbers should be until user decided to exit from the program. My code is below, calculation part goes well, but can't get it exit when user enter any other character.. How to fix it?

import java.io.*; 
public class q11

public static void main(String[]args)throws IOException
{
InputStreamReader ISR=new InputStreamReader(System.in);
BufferedReader BR=new BufferedReader(ISR);
while(true){
System.out.println("Enter..");
System.out.println("* : For multiplication");

[Code]...

View Replies View Related

Double RelativeFrequency Value Which Does Calculation / End Result Is Number With Lots Of Decimal Numbers

Nov 24, 2014

for (int i = 0; i < letters.length; i++) {
double relativeFreq = (onesAverage()/letters[i]);
char a = characters.charAt(i);
double j = score[i];
System.out.printf();//ToDo

Above is my current code. Basically- There is a string called characters of length 26 (1 char for each letter in alphabet), a double relativeFrequency value which does a calculation and the end result is a number with lots of decimal numbers. The score array has set double values within the array.

What I want to do is create a print f statement where I print out each of the values I initialized above WITH specific amounts of spaces in between. So it should be in this order:

a (spaces) j (spaces) relativeFreq (newLine).

Between J and relativeFreq there should be 4 spaces, however if the value in relativeFreq is greater than 10 (it won't be greater than 100)- then there should be 3 spaces. Everytime I try to create a printf statement my code ends up crooked for some of the values.

for (int i = 0; i < letters.length; i++) {
double relativeFreq = (onesAverage()/letters[i]);
char a = characters.charAt(i);
double j = score[i];
System.out.printf("%c %.4s %.4s%n",a, j, relativeFreq);

View Replies View Related

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 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

Create Little Program Which Enter Number / Program Says Triangle Exist Or Not

Mar 16, 2014

i want create little program which enter the number, ant program says triangle exist or not. So code :

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[code]...

So when i put first num like 1, next num like 2 and next num like 100 , program says Triangle exist.

View Replies View Related

Program To Open Excel Sheet From Java Program

Apr 16, 2014

Have written a program to open Excel sheet from java program.Below line works fine.

Process p = Runtime.getRuntime().exec(new String[]{""C:Program Files (x86)Microsoft OfficeOffice12Excel.EXE"","C:UsersRASHPA~ 1.ORAAppDataLocalTempExport_xl420314062726 9379706.xls"});

But below code gives error i.e. Executable name has embedded quote, split the arguments

String path = "C:Program Files (x86)Microsoft OfficeOffice12Excel.EXE";
String file = "C:UsersRASHPA~1.ORAAppDataLocalTempEx port_xl4203140627269379706.xls";

Process p = Runtime.getRuntime().exec(new String[]{"""+path+""" + ","+file});

I am using java 1.6.

View Replies View Related

Program That Links Several GUI As Menu Based Program

Dec 17, 2014

In a project for school. I have a program that links several GUI's as a menu based program. What I am trying to accomplish is when one of the previous GUI's is closed that it doesn't terminate the entire program. There is a lot of classes in the entire project so I'd prefer not to paste all the code here, but if it is necessary I will do so.

View Replies View Related

Creating A Program That Will Compile And Run Another Java Program

Feb 20, 2014

I'm creating a program that will compile and run another java program:Lets say I have a program in directory

D:HelloWorldsrc
and compiled program will be in
D:HelloWorldin
inside src and bin is a folder hello (that's a package)

package hello;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
System.out.println("Hello World");
}
}

This program will be run by another program (that's the program that I am creating).Here is the code of my program:

package runnercompiler;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class RunnerCompiler {
 
[code]....

View Replies View Related







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