Results 21 to 29 of 29
- 02-15-2009, 04:36 AM #21
-
I hope to god you aren't holding your breath waiting...
- 02-16-2009, 05:15 PM #23
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
I have it done im just occupied with finishing a website , anwho havent been in college to get it its rag week here ...if anyone knows what that is ...pure drunknness all week ...btw im irish lol :)
- 03-09-2009, 03:32 PM #24
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
sorry for the late reply lol
ok i have my code off my school server :)
here it is i would like some help if possible to help me improve this code , its fairly basic tho.
Java Code:* * ProgrammingAssignment application * * @author * @version 1.02009/3/6 */ public class ProgrammingAssignment { public static void main(String[] args) { //Input all integers involved here int music=0; int Rap=0; int Rock=0; int Alternative=0; int Techno=0; int Dance=0; int j; for(j = 1; j < 21; j = j + 1 ){ //Insert Screen Output Messages Screen.newline(); Screen.message(Favourite Music); Screen.newline(); Screen.message(1.Rap,2.Rock,3.Alternative,4.Techno,5.Dance); Screen.newline(); Screen.message(Insert Favourite Type of Music Here); music = Keyboard.readInt(); //Checking user input and increasing the appropiate music type by 1 if (music==1) Rap=Rap + 1; else if (music==2) Rock=Rock + 1; else if (music==3) Alternative=Alternative + 1; else if (music==4) Techno=Techno + 1; else if (music==5) Dance=Dance + 1; else Screen.message(Invalid Number); //Input messages which describe what students like Screen.newline(); Screen.message(Number Of Students Who like Rap Are); Screen.writeint(Rap); Screen.newline(); Screen.message(Number Of Students Who like Rock); Screen.writeint(Rock); Screen.newline(); Screen.message(Number Of Students Who Like Alternative); Screen.writeint(Alternative); Screen.newline(); Screen.message(Number Of Students Who Like Techno); Screen.writeint(Techno); Screen.newline(); Screen.message(Number Of Students Who Like Dance); Screen.writeint(Dance); Screen.newline(); //An if function which says whether people like or dislike the music type if (Rap > 10) Screen.message(people who love rap); else Screen.message(people who dont like rap); Screen.newline(); if (Rock > 10) Screen.message(people who love rock); else Screen.message(people who dont like rock); Screen.newline(); if (Alternative > 10) Screen.message(people who love alternative); else Screen.message(people who dont like alternative); Screen.newline(); if (Techno > 10) Screen.message(people who love techno); else Screen.message(people who dont like techno); Screen.newline(); if (Dance > 10) Screen.message(people who love dance); else Screen.message(people who dont like dance); Screen.newline(); } } }Last edited by javaNoob2; 03-09-2009 at 03:52 PM. Reason: Code tags /spelling mistakes
- 03-09-2009, 03:42 PM #25
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
When you post a code segment again in a forum, please use code tags. Un-formatted codes are hard to read.
- 03-09-2009, 03:50 PM #26
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
- 03-09-2009, 03:54 PM #27
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
NP, that's much better. Now let see what can we do on this code.
- 03-09-2009, 06:02 PM #28
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
can you say what you would like to "improve"?
personally, i'd remove as much from the main method as possible.
also, what is this Screen class you use? i've never seen that before...
- 03-09-2009, 06:31 PM #29
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
JAVA and XML Problem
By jackchang in forum XMLReplies: 4Last Post: 02-22-2009, 08:28 PM -
Problem in java
By saytri in forum New To JavaReplies: 4Last Post: 01-16-2008, 10:09 PM -
Problem in java
By saytri in forum New To JavaReplies: 6Last Post: 01-09-2008, 04:13 PM -
JAVA if problem
By toby in forum New To JavaReplies: 2Last Post: 07-25-2007, 07:58 PM -
java SE 6 problem
By techlance in forum Java AppletsReplies: 1Last Post: 06-28-2007, 10:10 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks