Off-topic Talk Where overpaid, underworked S2000 owners waste the worst part of their days before the drive home. This forum is for general chit chat and discussions not covered by the other off-topic forums.

Need Java Help

Thread Tools
 
Old Apr 13, 2011 | 08:59 AM
  #1  
Angerman's Avatar
Thread Starter
Registered User
 
Joined: Jan 2010
Posts: 5,205
Likes: 1
From: MD
Default Need Java Help

Can someone write this code for me? I have no idea WTF



Given the following if, if-else statement:

if ((i == 3)
{
n = 1;
k = 5;
}
else if (i == 4)
{
n = 5;
}
else if (i == 6)
{
n = 6;
}
else
{
n = 0;
}

In the above code i, k, and n are int variables. Rewrite the above using a switch statement. Include use of Scanner for user input for the variable "i" AND display the end result of the variable "n". Also display the value of "k".
Reply
Old Apr 13, 2011 | 09:12 AM
  #2  
thebig33tuna's Avatar
 
Joined: Jan 2007
Posts: 32,283
Likes: 0
From: Cincinnati, OH
Default

Seriously?
Reply
Old Apr 13, 2011 | 09:29 AM
  #3  
mxt_77's Avatar
Registered User
 
Joined: Jan 2003
Posts: 8,482
Likes: 3
From: Wylie, TX
Default

Go to the back of the class.



... and do your own homework, slacker.
Reply
Old Apr 13, 2011 | 10:47 AM
  #4  
Joeh's Avatar
15 Year Member
Liked
 
Joined: Apr 2009
Posts: 1,554
Likes: 4
From: London
Default

Just google switch statement in Java, you should be able to work it out yourself!

No good making other people do your homework!
Reply
Old Apr 13, 2011 | 11:00 AM
  #5  
Roflcopter's Avatar
 
Joined: Apr 2007
Posts: 40,663
Likes: 2,264
Default

Switch is easy... I could easily do it for you, but then neither one of us would get anything out of it.
Reply
Old Apr 13, 2011 | 11:12 AM
  #6  
Joeh's Avatar
15 Year Member
Liked
 
Joined: Apr 2009
Posts: 1,554
Likes: 4
From: London
Default

Well there's that and also he wouldn't learn anything if we just done it!

I suppose he should just have a go at it and post it up [code] tags, I'll give feedback & I'm sure there are others who would too.
Reply
Old Apr 13, 2011 | 01:54 PM
  #7  
senor_flojo's Avatar
Registered User
 
Joined: May 2008
Posts: 11,074
Likes: 0
From: All up in your inner tubes. Whatcha gonna do sucka?
Default

you don't want to make angerman angry, do you?



9,991
Reply
Old Apr 14, 2011 | 08:55 AM
  #8  
Angerman's Avatar
Thread Starter
Registered User
 
Joined: Jan 2010
Posts: 5,205
Likes: 1
From: MD
Default

I kind of figured it out but I couldn't get it to run. I'm starting to remember some stuff from 106 when I took it last year.
Reply
Old Apr 15, 2011 | 06:40 AM
  #9  
RedCelica's Avatar
20 Year Member
Liked
Loved
Community Favorite
 
Joined: Apr 2002
Posts: 15,342
Likes: 103
From: Raleigh
Default

System.out.println("Do your own work and stop being a moron");

http://download.oracle.com/javase/tu...ts/switch.html
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
zhan
Off-topic Talk
11
Jul 11, 2006 11:39 AM
oah4566
Off-topic Talk
2
May 18, 2004 03:42 PM
mav
Off-topic Talk
3
Nov 10, 2003 11:36 AM
jaynite
Off-topic Talk
3
Jan 2, 2002 01:59 AM




All times are GMT -8. The time now is 03:22 AM.