Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29
  1. #21
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

  2. #22
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I hope to god you aren't holding your breath waiting...

  3. #23
    javaNoob2 is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default

    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 :)

  4. #24
    javaNoob2 is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default 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 04:52 PM. Reason: Code tags /spelling mistakes

  5. #25
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    When you post a code segment again in a forum, please use code tags. Un-formatted codes are hard to read.

  6. #26
    javaNoob2 is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    When you post a code segment again in a forum, please use code tags. Un-formatted codes are hard to read.

    Right sorry about that fixed it just there :D

  7. #27
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  8. #28
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    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...

  9. #29
    javaNoob2 is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default

    Sorry if i dint make it clear lol . I kinda want to know about different ways of doing this assignment maybe changing my code a bit etc. Im still new to java only have a few months experience with it. The class file i used is EasyI0.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. JAVA and XML Problem
    By jackchang in forum XML
    Replies: 4
    Last Post: 02-22-2009, 09:28 PM
  2. Problem in java
    By saytri in forum New To Java
    Replies: 4
    Last Post: 01-16-2008, 11:09 PM
  3. Problem in java
    By saytri in forum New To Java
    Replies: 6
    Last Post: 01-09-2008, 05:13 PM
  4. JAVA if problem
    By toby in forum New To Java
    Replies: 2
    Last Post: 07-25-2007, 08:58 PM
  5. java SE 6 problem
    By techlance in forum Java Applets
    Replies: 1
    Last Post: 06-28-2007, 11:10 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
  •