[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]

Any Java programmers here?

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: 2

File: Capture.png (4KB, 269x105px) Image search: [Google]
Capture.png
4KB, 269x105px
Any Java programmers here?
>>
public class Flan {


public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("How old is your cat?: ");
int age = input.nextInt();
System.out.print("How many years have you had your cat? ");
int time = input.nextInt();
int diff = age - time;


int age2 = ((age - 2) * 4) + 24;
int diff2 = ((diff - 2) * 4) + 24;


if (age == 1) {
System.out.println("Your cat is approximately 15 years old.");
if (age == 1 && age > time) {
System.out.println("You've had it since it was a baby!");
}
if (age == 1 && age < time){
System.out.println("How the hell did you have your cat longer than it has existed for?");
}
}
if (age == 2) {
System.out.println("Your cat is approximately 24 years old");
if (age == 2 && age > time && time == 2){
System.out.println("You've had it since he was a baby!");
}
if (age == 2 && age > time && time == 1){
System.out.println("You've had your cat since it was a 15 year old!");
}
if (age == 2 && age < time){
System.out.println("How the hell did you have your cat longer than it existed for?");
}
}
if (age > 2) {
System.out.println("Your cat is approximately " + age2 + " Years old");
if (age > 2 && age == time){
System.out.println("You've had it since he was a baby!");
}
if (age > 2 && age > time){
System.out.println("You've had it since it was a " + diff2 + " year old");
}
if (age > 2 && age < time){
System.out.println("How the hell did you have your cat longer than it existed for?");
}

}

}
>>
goodevening sir how can i help this evening sir
>>
>>57360651
Java is a poo language.
>>
>>57360651
what is this 30 seconds into your first day of cs1?? what u need help wit nigga
>>
Rofl. Only using if loops. Go read your lecture slidea and fuck off OP.
>>
>>57360651
might as well ask
>anyone here named Pajeet from Verizon
>>
>>57362703
> if loops
Huehuehue

Also OP holy fuck this better be your first time ever writing code
>>
>>57360651
yes this is java programmer how am I assist you today?
>>
>>57362753
Prateek from AT&T here.
life is suffering.
>>
>if
>if
>if
>if
Good to know I have to worry about you competing in the job market.
>>
>>57362753
This is rajeesh from comcast
>>
>>57360651
not a good look. Plus this {
} is a pet peeve of mine. I was taught that good form meant brackets begin:

{
{
{
// You're a fag
}
}
} and end in line with each other so you can tell what the fuck you're looking at
>>
>>57362821
> Not knowing 4chan fucks up the format
Upvoted
>>
>>57362812
At my shop we hired a pooinloo to do all of our QA like 6 months ago, manager-level position, at least 6 figure salary. since then he's literally put in two code commits and spent the rest of his time playing pool and bugging everyone around him for help with the most basic shit (like how to fucking SSH). I'm convinced you have to be literally retarded to not find a decent programming job
>>
>>57360653
So this... is the power of Java... Woah...
>>
>>57362790
You forgot to call him sir, you're fired
>>
>>57360653
> Not even a fucking else
It hurts.
>>
>>57360653
obama?
>>
Real talk does it really matter if you use if, if/else or swtich case when even the shittiest computers you can buy come with at least an i5 and 8gb of RAM?
So what if your program has to go through a couple more instructions? It's not like you have your processor constantly at 100%
>>
>>57360653
Missing a closing bracket for class, and import for Scanner.
>>
>>57362929

Yes. Time complexity.
>>
>>57362956
>conditional statements have bearing on time complexity
>>
>>57362929
this line of thinking is how bloatware and exploits form
>>
>>57360653
Why do you even need (age == 1) and (age == 2)? Is that some sort of requirement?

import java.util.Scanner;

public class Flan {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.print("How old is your cat?: ");
int age = input.nextInt();

System.out.print("How many years have you had your cat? ");
int time = input.nextInt();

int diff = age - time;
int age2 = ((age - 2) * 4) + 24;
int diff2 = ((diff - 2) * 4) + 24;

System.out.println("Your cat is approximately " + age2 + " Years old");

if (age == time)
System.out.println("You've had it since he was a baby!");
else if (age > time)
System.out.println("You've had it since it was a " + diff2 + " year old");
else
System.out.println("How the hell did you have your cat longer than it existed for?");
}
}


I'm far from an expert, but this should work fine.
>>
this is /g/, if you're not writing haskell you're not welcome.
>>
File: hqdefault.jpg (27KB, 480x360px) Image search: [Google]
hqdefault.jpg
27KB, 480x360px
>>57360651
>>
>>57363435
> Title is in english
> Video is in Hindi
What?
Thread posts: 28
Thread images: 2


[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.