Results 1 to 5 of 5
- 12-22-2010, 01:04 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 3
- Rep Power
- 0
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.
- 12-22-2010, 01:36 PM #2
What do you expect this to do:
That violates basic Java syntax, and I'd suggest you go back through the basic tutorials: The Java™ TutorialsJava Code:System.out.println("Number Of Hens =") = hens;
I would guess that you're looking for something like this:
PS- That's what code tags are for. Learn 'em, use 'em, love 'em.Java Code:System.out.println("Number Of Hens = " + hens);
- 12-22-2010, 01:50 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 3
- Rep Power
- 0
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.
- 12-22-2010, 01:55 PM #4
- 12-22-2010, 02:32 PM #5
And of course this is crossposted: Just a bit of advice on my first program. (Beginning Java forum at JavaRanch)
Similar Threads
-
How to make a program like this? please give me advice
By 3c4hy0 in forum Advanced JavaReplies: 1Last Post: 08-13-2010, 08:13 AM -
Im new n looking for an advice
By azlynn in forum New To JavaReplies: 2Last Post: 12-10-2009, 02:47 AM -
advice on good Java book(s)
By monia in forum New To JavaReplies: 4Last Post: 09-16-2009, 09:50 AM -
Some advice please!
By awebbtt in forum New To JavaReplies: 3Last Post: 02-02-2009, 07:23 PM -
Advice on best method for....
By shaungoater in forum Java 2DReplies: 1Last Post: 06-23-2008, 07:36 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks