Results 1 to 5 of 5
  1. #1
    allen1952 is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default Just some advice on my first program in java.

    posted Today 05:01:36
    Hi All, Well, I have been studying Java for just over a month and I have almost finished my first program. But as you see I am stuck. Below is a copy of the code for a program I wrote MANY years ago in Tandy Basic, written in Java. I don't understand why my System.out.println call won't work. A word of why would help. I don't want you to fix it just let me know how to fix it myself. Any help would be great. Here is the code:


    Java Code:
    /** 
    * 
    */ 
    package EggsProfitLoss; 
    
    /** 
    * @author Michael Humphreys 
    * This program was origanaly written in TandyBasic many years ago 
    * This is an updated java program. 
    * 
    */ 
    public class chickens { 
             public static void main(String [] args) { 
                   int chickens = 110; 
                   int hens = 100; 
                   int numberOfEggsLaid = 110; 
                  double costOfFeed = 25.00; 
                  double cost; 
                  double costOfEggs = cost*chickens; 
                  cost = costOfFeed / chickens; 
    System.out.println("Number Of Hens =") = hens; 
    System.out.println("Number Of Eggs Laid =") = numberOfEggsLaid; 
    System.out.println("CostOf Feed =") = costOfFeed; 
    System.out.println("Cost Of Eggs = ") = cost; 
    System.out.println("Profit Or Loss = ") = costOfFeed-cost; 
    } 
    
    }
    Last edited by allen1952; 12-22-2010 at 02:01 PM. Reason: bad code presentation ...no formating.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,993
    Rep Power
    9

    Default

    What do you expect this to do:

    Java Code:
    System.out.println("Number Of Hens =") = hens;
    That violates basic Java syntax, and I'd suggest you go back through the basic tutorials: The Java™ Tutorials

    I would guess that you're looking for something like this:

    Java Code:
    System.out.println("Number Of Hens = " + hens);
    PS- That's what code tags are for. Learn 'em, use 'em, love 'em.

  3. #3
    allen1952 is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default Solved Thank you

    OK I used the suggestions you have made and it fixed the problem with my code.
    Sorry i don't understand what you mean about code tags ...if you would explain i would appreciate it ty.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,993
    Rep Power
    9

    Default

    Quote Originally Posted by allen1952 View Post
    Sorry i don't understand what you mean about code tags ...if you would explain i would appreciate it ty.
    If you press the "Quote" button on my post, you'll see the proper way to use code tags.

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,993
    Rep Power
    9

Similar Threads

  1. Replies: 1
    Last Post: 08-13-2010, 08:13 AM
  2. Im new n looking for an advice
    By azlynn in forum New To Java
    Replies: 2
    Last Post: 12-10-2009, 02:47 AM
  3. advice on good Java book(s)
    By monia in forum New To Java
    Replies: 4
    Last Post: 09-16-2009, 09:50 AM
  4. Some advice please!
    By awebbtt in forum New To Java
    Replies: 3
    Last Post: 02-02-2009, 07:23 PM
  5. Advice on best method for....
    By shaungoater in forum Java 2D
    Replies: 1
    Last Post: 06-23-2008, 07:36 PM

Posting Permissions

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