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 04-13-2011, 08:59 AM
  #1  
Registered User
Thread Starter
 
Angerman's Avatar
 
Join Date: Jan 2010
Location: MD
Posts: 5,205
Likes: 0
Received 1 Like on 1 Post
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".
Old 04-13-2011, 09:12 AM
  #2  

 
thebig33tuna's Avatar
 
Join Date: Jan 2007
Location: Cincinnati, OH
Posts: 32,283
Likes: 0
Received 0 Likes on 0 Posts
Default

Seriously?
Old 04-13-2011, 09:29 AM
  #3  
Registered User
 
mxt_77's Avatar
 
Join Date: Jan 2003
Location: Wylie, TX
Posts: 8,482
Likes: 0
Received 2 Likes on 2 Posts
Default

Go to the back of the class.



... and do your own homework, slacker.
Old 04-13-2011, 10:47 AM
  #4  

 
Joeh's Avatar
 
Join Date: Apr 2009
Location: London
Posts: 1,554
Received 4 Likes on 3 Posts
Default

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

No good making other people do your homework!
Old 04-13-2011, 11:00 AM
  #5  

 
Roflcopter's Avatar
 
Join Date: Apr 2007
Posts: 40,663
Received 2,264 Likes on 1,414 Posts
Default

Switch is easy... I could easily do it for you, but then neither one of us would get anything out of it.
Old 04-13-2011, 11:12 AM
  #6  

 
Joeh's Avatar
 
Join Date: Apr 2009
Location: London
Posts: 1,554
Received 4 Likes on 3 Posts
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.
Old 04-13-2011, 01:54 PM
  #7  
Registered User

 
senor_flojo's Avatar
 
Join Date: May 2008
Location: All up in your inner tubes. Whatcha gonna do sucka?
Posts: 11,074
Likes: 0
Received 0 Likes on 0 Posts
Default

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



9,991
Old 04-14-2011, 08:55 AM
  #8  
Registered User
Thread Starter
 
Angerman's Avatar
 
Join Date: Jan 2010
Location: MD
Posts: 5,205
Likes: 0
Received 1 Like on 1 Post
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.
Old 04-15-2011, 06:40 AM
  #9  
Moderator

 
RedCelica's Avatar
 
Join Date: Apr 2002
Location: Raleigh
Posts: 15,346
Received 95 Likes on 73 Posts
Default

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

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



Quick Reply: Need Java Help



All times are GMT -8. The time now is 11:25 AM.