d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Another Java Beginner Error > Help Please :)
Add Reply New Topic New Poll
Member
Posts: 19,377
Joined: Jul 10 2007
Gold: 4,678.60
Sep 16 2013 11:52am
The issue is with the very last attempt to declare the TOTALTAXES
how do I add all the varriables so i can do GROSS - TOTALTAXES





Code

import java.util.*;

public class deductions
{
static Scanner console = new Scanner(System.in);
 public static void main(String arg[])
 {
        //Declaring constants
  final double Federal = .15;
  final double State = .035;
  final double SSTax = .0575;
  final double Medicare = .0275;
  final double PensionPlan = .05;
  final double Insurance = 75.00;

        //Gathering Information
  System.out.println("Enter Your First Name");
  String FNAME = console.next();
  System.out.println("Enter Your Last Name");
  String LNAME = console.next();
  System.out.println("Please Enter Gross Wages");
  double GROSS = console.nextDouble();
 
        //outputting tax values
  System.out.println("Name: " + FNAME  + " " + LNAME);
  System.out.println("Federal Taxes: $" + (Federal * GROSS) );
  System.out.println("State Taxes: $" + (State * GROSS) );
  System.out.println("Social Security Taxes: $" + (SSTax * GROSS) );
  System.out.println("Federal Taxes: $" + (Medicare * GROSS) );
  System.out.println("Federal Taxes: $" + (PensionPlan * GROSS) );
  System.out.println("Insurance: $" + (Insurance) );
 
  double TOTALTAXES (Federal + State + SSTax + Medicare + PensionPlan + Insurance);
 
  System.out.println("Net Pay: $" + (GROSS - TOTALTAXES) );
Member
Posts: 2,757
Joined: Nov 26 2007
Gold: 1,214.81
Sep 16 2013 12:00pm
double TOTALTAXES = ((Federal + State + SSTax + Medicare + PensionPlan) * GROSS) + Insurance ;


and your naming conventions are wrong

all your constants should be all capital letters...
Federal => FEDERAL
State => STATE

non-constants like should be lowercase, and each word after beginning with uppercase

FNAME => fName
LNAME => lName
GROSS => gross
TOTALTAXES => totalTaxes

Also, if you have a variable name with all capital letters and more than 1 word, use _ to separate the words. Ex. TOTALTAXES => TOTAL_TAXES

This post was edited by labatymo on Sep 16 2013 12:04pm
Member
Posts: 19,377
Joined: Jul 10 2007
Gold: 4,678.60
Sep 16 2013 12:06pm
Quote (labatymo @ Sep 16 2013 01:00pm)
double TOTALTAXES = ((Federal + State + SSTax + Medicare + PensionPlan) * GROSS) + Insurance ;


ah, thank you soo much!


its only about our 3rd week ( as you can probs tell) so forgive me for issues like this, i will change this, thanks.
Quote (labatymo @ Sep 16 2013 01:00pm)
double TOTALTAXES = ((Federal + State + SSTax + Medicare + PensionPlan) * GROSS) + Insurance ;


and your naming conventions are wrong

all your constants should be all capital letters...
Federal => FEDERAL
State  => STATE

non-constants like should be lowercase, and each word after beginning with uppercase

FNAME => fName
LNAME => lName
GROSS => gross
TOTALTAXES => totalTaxes

Also, if you have a variable name with all capital letters and more than 1 word, use _ to separate the words. Ex. TOTALTAXES => TOTAL_TAXES



This post was edited by lilwillis121 on Sep 16 2013 12:07pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll