Results 1 to 9 of 9
Like Tree3Likes
  • 2 Post By Junky
  • 1 Post By gimbal2

Thread: how to use input on java!

  1. #1
    hammodi is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

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

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,651
    Rep Power
    5

    Default Re: how to use input on java!

    Check the Scanner class in the JDK API.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    hammodi is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default Re: how to use input on java!

    Quote Originally Posted by jim829 View Post
    Check the Scanner class in the JDK API.

    Regards,
    Jim
    i know how to use the Scanner but i don't know to use the input data. multiple data with different types. string/int/double. how do i do that?

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,651
    Rep Power
    5

    Default Re: how to use input on java!

    Are you saying you don't know what to do with strings, integers, or doubles?

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    hammodi is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default Re: how to use input on java!

    Quote Originally Posted by jim829 View Post
    Are you saying you don't know what to do with strings, integers, or doubles?

    Regards,
    Jim
    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.

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,651
    Rep Power
    5

    Default 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,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  7. #7
    hammodi is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default Re: how to use input on java!

    Quote Originally Posted by jim829 View Post
    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,
    Jim
    i know. Eclipse is craping out on me. does not let me to debug. does not save files. does not change the program that runs. does it tell me if i have an error or not. i miss VB days.

  8. #8
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default 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.
    gimbal2 and JosAH like this.

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,050
    Rep Power
    6

    Default Re: how to use input on java!

    Quote Originally Posted by Junky View Post
    I find that hard to believe. Eclipse is just a tool. It does what you tell it to do.
    A tool that works just fine for people who actually know what they're doing, I might add.
    JosAH likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 1
    Last Post: 11-14-2011, 01:03 PM
  2. Replies: 0
    Last Post: 10-14-2011, 12:33 AM
  3. Java Input
    By Jathu in forum New To Java
    Replies: 4
    Last Post: 03-31-2011, 03:27 AM
  4. Input technique for unknown lines of input
    By ducreative in forum New To Java
    Replies: 16
    Last Post: 09-23-2009, 09:26 AM
  5. how to take input and verify input in Java programs
    By bilal_ali_java in forum Advanced Java
    Replies: 0
    Last Post: 07-21-2007, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •