Thread: Close

Results 1 to 8 of 8
  1. #1 Close 
    Extreme Donator


    Join Date
    Nov 2011
    Posts
    311
    Thanks given
    15
    Thanks received
    94
    Rep Power
    361
    Close
    Reply With Quote  
     

  2. #2  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    Code:
    int daysTillWeekend = day == 0 ? 0 : 6 - day;
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Endeavor

    Mikey`'s Avatar
    Join Date
    Dec 2007
    Posts
    4,434
    Thanks given
    715
    Thanks received
    1,435
    Rep Power
    1202
    Code:
    public class MidtermYourName {
    
    	public static void main(String[] args) {
    		int day = (int) (Math.random() * 7);
    		
    		System.out.println("The random number here is " + day +";"
    				+ " therefore, the day is " + getName(day) + ".");
    		
    		if (day != 6 && day != 0) {
    			int remaining = 6 - day;
    			System.out.println("It will take " + remaining + " days to get to the next weekend.");
    		} else {
    			System.out.println("Enjoy!");
    		}
    	}
    	
    	public static String getName(int day) {
    		switch(day) {
    		case 0:	return "Sunday";
    		case 1:	return "Monday";
    		case 2:	return "Tuesday";
    		case 3:	return "Wednesday";
    		case 4:	return "Thursday";
    		case 5:	return "Friday";
    		case 6:	return "Saturday";
    		}
    		
    		return null;
    	}
    }
    Reply With Quote  
     

  5. Thankful user:


  6. #4  
    Extreme Donator


    Join Date
    Nov 2011
    Posts
    311
    Thanks given
    15
    Thanks received
    94
    Rep Power
    361
    Quote Originally Posted by Harlan View Post
    Code:
    int daysTillWeekend = day == 0 ? 0 : 6 - day;

    Thanks for that, Got the exam finished and working flawlessly

    Quote Originally Posted by Mikey` View Post
    Code:
    public class MidtermYourName {
    
    	public static void main(String[] args) {
    		int day = (int) (Math.random() * 7);
    		
    		System.out.println("The random number here is " + day +";"
    				+ " therefore, the day is " + getName(day) + ".");
    		
    		if (day != 6 && day != 0) {
    			int remaining = 6 - day;
    			System.out.println("It will take " + remaining + " days to get to the next weekend.");
    		} else {
    			System.out.println("Enjoy!");
    		}
    	}
    	
    	public static String getName(int day) {
    		switch(day) {
    		case 0:	return "Sunday";
    		case 1:	return "Monday";
    		case 2:	return "Tuesday";
    		case 3:	return "Wednesday";
    		case 4:	return "Thursday";
    		case 5:	return "Friday";
    		case 6:	return "Saturday";
    		}
    		
    		return null;
    	}
    }
    Also thanks for helping too, I like how you did that my professor would of probably gave me bonus points if I just copied what you put. But this is a learning experience and I wanted to learn in the process. Might just save what you wrote for any future help lol
    Reply With Quote  
     

  7. Thankful user:


  8. #5  
    Registered Member

    Join Date
    Dec 2011
    Posts
    1,615
    Thanks given
    1,971
    Thanks received
    819
    Rep Power
    1049
    Quote Originally Posted by VisionaryPS View Post
    Also thanks for helping too, I like how you did that my professor would of probably gave me bonus points if I just copied what you put. But this is a learning experience and I wanted to learn in the process. Might just save what you wrote for any future help lol
    Woah, never thought I'd see that statement on this site Kudos to you.
    Reply With Quote  
     

  9. #6  
    Extreme Donator


    Join Date
    Nov 2011
    Posts
    311
    Thanks given
    15
    Thanks received
    94
    Rep Power
    361
    Quote Originally Posted by Mur View Post
    Woah, never thought I'd see that statement on this site Kudos to you.
    Reply With Quote  
     

  10. #7  
    oof


    Join Date
    Aug 2012
    Posts
    3,150
    Thanks given
    2,847
    Thanks received
    857
    Rep Power
    2260
    Quote Originally Posted by Mur View Post
    Woah, never thought I'd see that statement on this site Kudos to you.
    You'll only see that kind of post outside the rs development sections
    Reply With Quote  
     

  11. Thankful users:


  12. #8  
    Registered Member

    Join Date
    May 2008
    Posts
    446
    Thanks given
    136
    Thanks received
    52
    Rep Power
    355
    Code:
    import java.util.Random;
    
    public class MidtermExtea {
    
        private enum Day {
            Sunday,
            Monday,
            Tuesday,
            Wednesday,
            Thursday,
            Friday,
            Saturday;
    
            public int untilWeekend() {
                if(this == Saturday || this == Sunday)
                    return 0;
                return Saturday.ordinal() - this.ordinal();
            }
    
        }
    
        public static void main(String[] args) {
            Day[] days = Day.values();
            int random = new Random().nextInt(days.length);
            Day day = days[random];
            int untilWeekend = day.untilWeekend();
            System.out.println("The random number here is " + random + "; Therefore, the day is " + day.name() + ".");
            if(untilWeekend == 0)
                System.out.println("Enjoy!");
            else
                System.out.println("It will take " + untilWeekend + " " + (untilWeekend == 1 ? "day" : "days") + " to get to the next weekend.");
        }
    
    }

    Edit: Sorry, didn't notice you already finished your exam!

    Attached image

    (Click on the logo above to view our server!)
    Reply With Quote  
     

  13. Thankful users:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. what am I missing?? (map loading)
    By mige5 in forum Help
    Replies: 0
    Last Post: 10-28-2015, 06:39 PM
  2. Replies: 13
    Last Post: 09-09-2013, 08:33 PM
  3. Replies: 1
    Last Post: 11-07-2010, 04:41 AM
  4. data.dat what am i missing?
    By Help in forum Help
    Replies: 4
    Last Post: 11-06-2010, 06:01 PM
  5. What am I doing wrong?
    By Jay Dawg in forum Application Development
    Replies: 2
    Last Post: 06-28-2008, 06:57 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
  •