Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Calculation

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Calculation

    Hello
    When I compile the program it got no errors. But when I try to run it, it doesnot run the program. Need some help please. Thanks a lot
    /**********************************************************
     * Program Name   : Lab01 - Calculate Total Spending
     * Author         : Adam Bastola
     * Date           : September 22, 2014
     * Course/Section : CSC111 - 111
     * Program Description: This program will prompt users to input their
     *    monthly income, and their monthly expenses on rent, phone bill
     *    and utilities. The program will calculate sum for total expenses
     *    and calculate spending money by subtract total expenses from monthly income.
     *    This program will display monthly income, total expenses and spending
     *    money on to the monitor.
     *
     * Methods:
     * -------
     * main - calculates the sum, and diff
     *
     **********************************************************/
     
     
    public class Lab1
    {
     
       static Library myLib;
     
       /**********************************************************
        * Method Name    : main
        * Author         : Adam Bastola
        * Date           : September 22, 2014
        * Course/Section : CSC111 - 111
        * Program Description: This program will prompt users to input their
     	*    monthly income, and their monthly expenses on rent, phone bill
     	*    and utilities. The program will calculate sum for total expenses
     	*    and calculate spending money by subtract total expenses from monthly
     	*	 income. This program will display monthly income, total expenses and
     	*    spending money on to the monitor.
        *
        * BEGIN Calc Spending $
        *    Prompt user for monthly income
        *    Prompt user for rent bill
        *    Prompt user for phone bill
        *    Clear the screen
        *    Calculate total expenses
        *    Calculate Spending $
        *    Display results
        * END Calc Spending $
        **********************************************************/
     
       public static void main (String [] args)
       {
          //local constants
     
          //local variables
          int income;           //monthly income input by the user
          int rent;             //expense for rent input by user
          int phone;            //expense for phone input by user
          int utilities;        //expense for utilities input by user
          int totalExpenses;    //sum of expenses on rent, phone and utilities
          int spending;         //diff of income - totalExpenses
     
    	  Library myLib = new Library();//has methods to clear/pause screen
     
          /********************   Start main method  *****************/
     
          //prompt user for monthly income
          System.out.println("\n\n");
          System.out.print("\tEnter your monthly income : ");
          income = Keyboard.readInt();
     
          //prompt user for monthly rent
          System.out.print("\tWhat is your monthly rent: ");
          rent = Keyboard.readInt();
     
          //prompt user for phone bill
    	  System.out.print("\tWhat is your monthly phone bill: ");
          phone = Keyboard.readInt();
     
          //prompt user for second number
    	  System.out.print("\tWhat is your monthly utilities bill: ");
          utilities = Keyboard.readInt();
     
          //clear the screen
          myLib.clrscr();
     
          //Calculate Total Expeneses
          totalExpenses = rent + phone + utilities;
     
          //Calculate Spending
          spending = income - totalExpenses;
     
          //display the results of the calculations
          System.out.println("\n\n\n");
          System.out.println("\t   Monthly Budget\n");
          System.out.println("\tMonthly Income     : " + income);
          System.out.println("\tMonthly Expenses   : " + totalExpenses);
          System.out.println("\tSpending           : " + spending);
          System.out.println("\n\n\n\n\n\n\n\n\n\n\n");
     
          //pause the screen - this statement is not needed in this program
          //myLib.pause();
     
       } //end main method
     
    } //end Lab01[COLOR="Silver"]
     
    [/COLOR]

    --- Update ---

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no lib in java.librar
    y.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1857)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1119)
    at Library.<clinit>(Clrscr.java:8)
    at Lab1.main(Lab1.java:60)
    Press any key to continue . . .


    The above code is displayed when I run it
    Last edited by adam1991; September 21st, 2014 at 05:01 PM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 697 Times in 679 Posts

    Default Re: Calculation

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,399
    Thanks
    53
    Thanked 2,399 Times in 2,352 Posts

    Default Re: Calculation

    Where is the definition for the Library class? It looks like it needs some files to execute properly.
    Do you have instructions for how to use the Library class?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Sep 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calculation

    I have my Library.Class and Keyboard.Class stored in same folder as my Lb1.java if thats what your asking. Thank you

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,399
    Thanks
    53
    Thanked 2,399 Times in 2,352 Posts

    Default Re: Calculation

    It looks like the Library class uses some non-java code. Do you have instructions on how to use the Library class?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Sep 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calculation

    not really and I am kind of lost lol. But thanks alot for your help

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,399
    Thanks
    53
    Thanked 2,399 Times in 2,352 Posts

    Default Re: Calculation

    If you don't know how to use the Library class and it's giving you a problem, I recommend that you comment it out of your code so the java part of your program will execute without problems.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Sep 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calculation

    Where do i comment the code?

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,399
    Thanks
    53
    Thanked 2,399 Times in 2,352 Posts

    Default Re: Calculation

    Put // in the first column of the statements that use the Library class to make those statements a comment.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: July 26th, 2014, 04:38 AM
  2. BMI calculation
    By dantheman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 28th, 2012, 09:57 PM
  3. simulate calculation ?
    By meryqat in forum Java Theory & Questions
    Replies: 3
    Last Post: April 30th, 2012, 01:03 PM
  4. I need calculation
    By Swiss518 in forum Loops & Control Statements
    Replies: 7
    Last Post: January 27th, 2011, 12:26 PM
  5. RPM Calculation
    By fobos3 in forum Algorithms & Recursion
    Replies: 2
    Last Post: September 21st, 2010, 08:53 AM