Results 1 to 8 of 8
  1. #1
    HappyGirl1184 is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Java application

    I need to create a java application that determines if any of several department store customers have exceeded the credit limit on a charge account. I need to know the:
    a. account number
    b. balance at beginning of the month
    c. total of all items charged by t he customer this month
    d. total of all credits applied to the customer's account this month
    e. allowed credit limit.
    it needs to input these as integers, calculate the new balance (= beginning balance + charges - credits) display the new balance and if it exceeds the new balance it needs to display the message "credit limit exceeded"


    When I try to compile it, i get a lot of errors. How do I write the public void input values and how do i write the calculate and display the value? Help!

    Java Code:
    import java.util.Scanner;
    
    public class Credit
    {
            private int account;            // account number
            private int balance;            // starting balance
            private int charges;            // total charges
            private int credits;            // total credit
            private int creditLimit;        // new credit limit
            private int newBalance;         // new balance
    
    
    public void inputValues(){ 
    
    
    public void calculateAndDisplayBalance(){ 
    
       if ( newBalance > creditLimit)
          {
        	  System.out.printf("%s%d","\n\n\n -- Account ::" );
        	  System.out.printf("%s%d","\n -- Credit limit ::" );
        	  System.out.printf("%s%d","\n -- Total Credits ::" );
        	  System.out.printf("%s","\nCredit Limit Exceeded: " ); }
       }
    }
    Last edited by sunde887; 09-16-2011 at 12:45 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Java application

    i get a lot of errors.
    Please post them here.

    The code for your method definitions should be enclosed in { and }.
    It appears some } are missing.

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: Java application

    You also can't have methods defined inside other methods.

  4. #4
    HappyGirl1184 is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Re: Java application

    the errors that I'm receiving are "14:error: illegal start of expression
    public void calculateAndDisplayBalance(){

    it points to the p inpublic, the v invoid, and the first"("

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Java application

    Did you read post #2?

    Check your {}s.

  6. #6
    HappyGirl1184 is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Re: Java application

    I checked them. What do I need to put in between the brackets for the public void?

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Java application

    Nothing is needed for the code to compile without errors.

    What code you put in a method depends on what you want the method to do.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Java application

    As Norm says, count your brackets.
    Your code should have something like the following structure (note the brackets):
    Java Code:
    public class MyClass {
        private int someData;
    
        public void someMethod() {
            // Put some code in here...
        }
    
        public void someOtherMethod() {
        }
    }
    All the brackets match up (indenting properly helps in this, and helps others read your code).
    Each method has its own pair of {}.
    It's all wrapped in the {} for the class.

Similar Threads

  1. how to call Java Bean Ireport frm Java application
    By Prashant.surwade in forum Advanced Java
    Replies: 8
    Last Post: 05-06-2012, 04:39 PM
  2. Help with Java Application please...
    By berry88 in forum Java Applets
    Replies: 8
    Last Post: 08-13-2011, 10:00 PM
  3. Replies: 3
    Last Post: 12-04-2009, 01:10 PM
  4. Replies: 1
    Last Post: 08-05-2009, 03:43 AM
  5. Using Java in SWF Application
    By ajayk in forum SWT / JFace
    Replies: 0
    Last Post: 06-25-2008, 09:26 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
  •