Need Java Help
#1
Registered User
Thread Starter
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".
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".
#5
Switch is easy... I could easily do it for you, but then neither one of us would get anything out of it.
#6
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.
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.
Trending Topics
#9
Moderator
System.out.println("Do your own work and stop being a moron");
http://download.oracle.com/javase/tu...ts/switch.html
http://download.oracle.com/javase/tu...ts/switch.html
Thread
Thread Starter
Forum
Replies
Last Post
redhurley
Off-topic Talk
0
02-25-2004 03:29 PM