Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

i need help

Name: Anonymous 2010-10-17 3:13

hey /g/uy's i need a little help with this code for my coding class
java. I dont know the code to be able to type in a persons name
i need to input a person's name then be able to press enter and input a numbe

import java.util.Scanner;

public class Taxes{
public static void main(String[] args){
double net;
Scanner input = new Scanner(System.in);
System.out.println("Enter employee name: ");
System.out.println("Enter employee gross pay: ");
name = input.nextDouble();

final double fed = grossPay * .15;
final double state = grossPay * .035;
final double social = grossPay * .0575;
final double medicare = grossPay * .0275;
final double pension = grossPay * .05;
final double health = 75.00;

net = grossPay - fed - state - social - medicare - pension - health;

System.out.println("\t Gross Amount: " + grossPay + "\n" +
"\t Federal Tax: " + fed + "\n" +
"\t State Tax: " + state + "\n" +
"\t Social Security Tax: " + social + "\n" +
"\t Medicare/Medicaid Tax: " + medicare + "\n" +
"\t Pension Plan: " + pension + "\n" +
"\t Health Insurance: $" + 75 + "\n" +
"\t Net Pay: $" + net + "\n");
}
}

Name: Anonymous 2010-10-17 5:48

>>1
What you are looking for is the Scanner method called nextLine(). Don't forget that, if you're using it after inputting a number, for instance, you will have to call it once to get to the end of the current line (you may safely discard the result) and another time to actually fetch the contents next line. Basically, what the nextLine() it does is return all the characters until the end of the line. I hope this HELPED.

For further reference, don't hesitate to Google: http://www.google.com/search?q=java+scanner

>>3-5,6,8,10,12
Fuck off of /prague/.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List