[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Learning Java

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 28
Thread images: 3

File: java.png (39KB, 518x518px) Image search: [Google]
java.png
39KB, 518x518px
I am currently trying to learn Java and one of the things it wants me to do is use if statements. I am kind of stuck on this.

I am supposed to change part of my already established basic Hello program to add this at the end..

a. Instead of asking the user's age, instead ask "How much love do you need?" There are "3 use case" scenarios to consider:
i. Use Case 1: User enters 0 or a negative number
1. Print out the message "Everybody needs some love!"
ii. Use Case 2: User enters a number bigger than 10
1. Print out the message "You cannot handle that much love!"
iii. Use Case 3: User enters a number between 1 and 9
1. Use a loop to count from 1 to the number entered, and print each "I love you" number "way" or "ways" according to English grammar, on a separate line.
a. Example: If 2 is entered, then print:
I love you 1 way
I love you 2 ways

Any help here would be appreciated.
>>
do your own homework, Pajeet
>>
>>58697275

I actually came here before when I was learning Python and /g/ was very helpful and set me on the right track. I have looked up using if statements and I just do not get how to do it.
>>
If (condition) {
Code
} else if (another condition) {
Code
} else if (third condition) {
Code
} else { //this happens of none of the above conditions pass
Code
}
>>
You don't learn Java you just get continuously better at learning how to google things.
Learn a real language and leave Java to Pajeet.
>>
File: Hello.png (38KB, 1210x388px) Image search: [Google]
Hello.png
38KB, 1210x388px
>>58697440

I may be missing something but this is what I got when I tried to put in what I thought was right.
>>
>>58697547
Kill yourself
>>
>>58697547
it works the same damn way as python, just formatted with parenthesis and brackets. Use the damn name variable to do the checks in the if statement.
>>
>>58697547
Lmao
>>
>>58697547
Needs more semicolons dude
>>
>>58697547
Why did I waste my time...
>>
>>58697646
This

The compiler is even telling you this
>>
>>58697547
If you're going to skip class, just do yourself a favor and drop out now. You won't make it.
>>
>>58697646
>>58697664
Check his condition statements too. Lel.
>>
In the off chance you're not a troll, your condition statements are wrong.
>>
By the way, your condition statements should look like this.
 

public static void main(String[] args)
{
Scanner scanner = new Scanner(new InputStreamReader(System.in));
System.out.println("Please enter number of penis: ");
int input = scanner.nextInt();
if(input > 10) {
System.out.println("Your ass cannot handle that many penises");
} else if(input <= 0){
System.out.println("Everyone need a dick, even your cracker faggot ass.");
} else if(input == 1){
System.out.println("I am going to buttfuck you 1 way");
} else{
System.out.println("I am going to buttfuck you " + input + " ways");
}

}
>>
>>58697851
it needs to talk about love not penises
can you rewrite it?
>>
Create an integer to hold the love needed value, read it in the same way you read in age and name. For less than 0: if(love<=0) { /* do stuff */}

The others will be similar
if(love>=10)
if(love>0 && love<10)

You need to learn how basic conditional statements work before you even start on loops.
>>
>>58697878
Do it yourself faggot.
>>
Quality thread, OP, sides are broken.
>>
>>58697440
Holy shit use switch ffs
Oh
>>
>>58697547
Oh fuck this is golden
>>
File: 1455028244814.png (174KB, 1920x1080px) Image search: [Google]
1455028244814.png
174KB, 1920x1080px
r8 h8 masterb8
>>
>>58698122
>>>58697547
>Oh fuck this is golden
shut up pajeet, first learn some English
>>
>>58697547
thats not how you use if-statements.... like at all. some pajeet on youtube could teach you this shit in like 5 minutes, fucking idiot.
>>
So... when did Java start using IF statements?
>>
>>58699527
Uh, pretty sure it always did?
>>
>>58698536
>non-standard program
Thread posts: 28
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.