Results 1 to 9 of 9
Thread: how to use input on java!
- 09-08-2013, 10:28 PM #1
Member
- Join Date
- Sep 2013
- Posts
- 12
- Rep Power
- 0
how to use input on java!
i am using Eclipse IDE. and i want to do this!
its a payroll program where i take the persons name. and tax rate. and gross hourly charge. and hours worked to give him what are the exemptions and his net pay!
how do i do that? the problem i am having is that i don't know how to use the input that i take! neither string.int.double taking all these types at the same time. how do i do that and use the values.?
i also want to display his name again!
- 09-08-2013, 10:33 PM #2
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: how to use input on java!
Check the Scanner class in the JDK API.
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 09-08-2013, 10:36 PM #3
Member
- Join Date
- Sep 2013
- Posts
- 12
- Rep Power
- 0
- 09-08-2013, 10:41 PM #4
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: how to use input on java!
Are you saying you don't know what to do with strings, integers, or doubles?
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 09-08-2013, 10:45 PM #5
Member
- Join Date
- Sep 2013
- Posts
- 12
- Rep Power
- 0
Re: how to use input on java!
give me a minute. i will see what i can or know to do and i will report to u if i can do it or not!
this is what i came up with. my Eclispse won't work for some reason!
[php]import java.util.Scanner;
public class Ver1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Enter employee's name: ") ;
Scanner scanner= new Scanner(System.in);
String name= scanner.next()
System.out.println("Enter number of hours worked in a week: ");
Scanner scanner1= new Scanner( System.in);
int hours= scanner1.nextInt() ;
System.out.println("Enter hourly pay rate: ");
Scanner scanner2= new Scanner( System.in);
double rate= scanner2.nextDouble() ;
System.out.println("Enter federal tax withholding rate: ") ;
Scanner scanner3= new Scanner(System.in);
double fedtax= Scanner3.nextDouble() ;
System.out.println("Enter state tax withholding rate: ") ;
Scanner scanner4= new Scanner(System.in);
double statx= Scanner4.nextDouble() ;
double grosspay= hours*rate
System.out.println("Employee Name: " + name) ;
System.out.println("Hours Worked: " + hours) ;
System.out.println("Hourly Rate:$"+rate) ;
System.out.println("Gross Pay;$"+grosspay) ;
System.out.println("Deductions:")
System.out.println(" Federal Withholding (" + (fedtax*100.0) + "%) : "+ "$" + ((grosspay)-
grosspay* fedtax );
System.out.println(" State Withholding (" + (statax*100.0)+ "%) : " +"$"+ (grosspay-(grosspay*statax)) ;
System.out.printLn(" Total Deductions: $" +(grosspay*(statax+fedtax)) ;
System.out.println("Net Pay: $"+(grosspay-(grosspay*(statax+fedtax))) ; [php]
}
}Last edited by hammodi; 09-08-2013 at 11:03 PM.
- 09-08-2013, 11:10 PM #6
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: how to use input on java!
First, you have numerous syntax errors. You need to check case on you variables and methods. Check semi colons and also count parentheses on you print statements. Eclipse should flag these for you.
And you only need a single instance of Scanner.
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 09-08-2013, 11:21 PM #7
Member
- Join Date
- Sep 2013
- Posts
- 12
- Rep Power
- 0
- 09-09-2013, 05:09 AM #8
Re: how to use input on java!
I find that hard to believe. Eclipse is just a tool. It does what you tell it to do.
- 09-09-2013, 09:18 AM #9
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Similar Threads
-
Getting input from 3 input text boxes and store into 1 values
By niksipandit in forum New To JavaReplies: 1Last Post: 11-14-2011, 01:03 PM -
How do I creat a function that receive input and limits the input time
By itayjc in forum New To JavaReplies: 0Last Post: 10-14-2011, 12:33 AM -
Java Input
By Jathu in forum New To JavaReplies: 4Last Post: 03-31-2011, 03:27 AM -
Input technique for unknown lines of input
By ducreative in forum New To JavaReplies: 16Last Post: 09-23-2009, 09:26 AM -
how to take input and verify input in Java programs
By bilal_ali_java in forum Advanced JavaReplies: 0Last Post: 07-21-2007, 08:46 AM
Bookmarks