Results 1 to 3 of 3
  1. #1
    JohnSalx28 is offline Member
    Join Date
    Aug 2013
    Posts
    2
    Rep Power
    0

    Default Problem: New to this and cannot figure this one out.

    The Code
    Java Code:
    import java.util.Scanner;
    public class RevisedPayroll {
        
    /**
    * main method begins execution of Java application
    */
    
    public static void main(String[] args) {
    Scanner reader = new Scanner (System.in);               
            
            
    double PayRate;
    double RegHours;
    double WeeklyPay;
    double RegPay;
    char a;
          
    System.out.println("Employee name: ");
    String Name = reader.nextLine(); // read text
            
    if (a == 'n')
    {
    System.out.println( "Thank You! Have a nice day!" );
    }
    else if (a == 'y')
    {
            
    System.out.print("Rate of pay: ");//user input prompt
    PayRate = reader.nextDouble();//read numbers
    
    System.out.println("Reg hours worked: ");//user input prompt
    RegHours = reader.nextDouble();//read numbers
            
    RegPay = PayRate * RegHours;//calculation
            
    WeeklyPay = RegPay;//calculation
    
    while( WeeklyPay <= -1) {
    
    	System.out.println( "Payroll cannot be a negative number" );
    }
            
    System.out.println(Name);//prints text
            
    System.out.printf("$%.2f\n", WeeklyPay);
    
    System.out.println( "Would you like to do another employee? y/n");
    
    a = reader.next().charAt();
            
    
       } }//end method main
    
    }//end class RevisedPayroll
    ================================================== ================================================== ====================
    The Problem

    Ok so my problem is that on line 49 the a = reader.net().charAt(); line I get an error saying 'Method charAt in class String cannot be applied to given types;
    a = reader.net.().charAt();
    ^
    required: int
    found: no arguments
    reason: actual and formal argument lists differ in length
    1 error

    So what I am asking is what I can do to fix this? Also on a side question On the line where I put 'System.out.println( "Payroll cannot be a negative number" );, how can i get my program to stop there? Like just exit the program, at the moment it just keeps repeating the phrase.
    Last edited by JohnSalx28; 08-01-2013 at 10:23 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Problem: New to this and cannot figure this one out.

    Guide For New Members
    BB Code List - Java Programming Forum - Learn Java Programming

    Read those and edit your post. Also go through the Forum Rules, particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Problem: New to this and cannot figure this one out.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 5
    Last Post: 12-11-2011, 06:42 PM
  2. can someone please help me to figure this out >.<
    By lyzeofkiel in forum New To Java
    Replies: 11
    Last Post: 07-24-2011, 11:34 AM
  3. Replies: 7
    Last Post: 07-17-2010, 12:22 PM
  4. Unable to figure out this problem! jndi lookup exception.....
    By vrk in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 01-19-2009, 11:38 AM
  5. [SOLVED] Can't figure out my thread/awt problem
    By Zosden in forum Advanced Java
    Replies: 7
    Last Post: 07-29-2008, 05:13 PM

Tags for this Thread

Posting Permissions

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