Who wants to be Sup Forumsro of the year and help me write my last couple of programs for my Java class...

Who wants to be Sup Forumsro of the year and help me write my last couple of programs for my Java class? I had some shit come up and I got a week behind now all this shit is due tomorrow at midnight but I work from 2pm until 8pm.

Other urls found in this thread:

docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
twitter.com/NSFWRedditGif

good luck

well fuck....

bump

shit looks basic as fuck

What the fuck do you even have to do

one program is making something to calculate perimeters of a rectangle and adding a menu option in the test file

the other one is Payroll Modification Modify the payroll system of Figs 10.4 –10.9 to include private instance variable birthdate in class Employee. Use class Date of Fig 8.7 to represent an employee’s birthday. Add get methods to class Date. Assume that payroll is processed once per month. Create an array of Employee variables to store references to the various employee objects. In a loop, calculate the payroll for each Employee (polymorphic ally), and add a $100.00 bonus to the persons payroll amount if the current month is the one in which the Employee’s birthdate occurs.

the last one is two of them Write an application containing three parallel arrays that hold 10 elements each. The first array hold four-digit student ID numbers, the second array holds first names, and the third array holds the students’ grade point averages. Use dialog boxes to accept a student ID number and display the student’s first name and grade point average. If a match is not found, display an error message that includes the invalid ID number and allow the user to search for a new ID number.
and then
Create an application that contains an enumeration (enum) that represents the days of the week. Display a list of the days, then prompt the user for a day. Display business hours for the chosen day. Create your own business hours stored in an array; however, every day of the week should have different hours. Although companies do not normally have different business hours every day of the week, programming your code with this difference will help in finding and fixing coding errors.

usually I like to read everything but between work and the kids I fell behind. Its bad enough that there is really no video lessons with this class like my other online ones. I absolutely hate just reading a book and trying to figure it out but thats what its been so far.

OP if you can't do this simple shit how are you going to make it as a programmer?

But that is 99.9% of all programming in the real world there is no book to follow.

user these are seriously like 5 minute assignments, what class is this for?

This user knows the truth, fucking just finished up writing a multithreaded server today...google is god

its for an object oriented programming class its the entry level one, If I had more time I wouldn't be here asking for help. I really cant read then do I am more of a visual audio type person this has been horrible for me.
I'm not really trying to program my major is in modeling but this is part of it I guess.

yeah I get that that's why I was asking for help not the whole answer. I don't just want shit given to me.

I'll bite I guess for a little bit, tired as piss but fuck it. What do you need user?

well I got frustrated with the first one so I am trying to start from scratch with the rectangle one

It's been ages since I have worked in Java, what are you using to generate the dialog boxes? Joption pane is the first thing I see pop in google

yeah I can do that I guess, what I am having problems with is the differences of using int float or double. I am having a hard time figuring which one to use for some reason I just don't get it.

dude, you're a fucktard.

when i was at your level, i had no idea that 1000 hours of coding in java, MIPS assembly and C would only show me that i needed 10000 more.

stop wasting your time here. you need to flip your entire concept of lifestyle. you don't code in your life... you try to have life while you're coding. you need to end up performing the big flip where you realize that you can't stop thinking about coding to even watch a movie and it keeps creeping in and you keep thinking about it and reaching for a whiteboard.

there is no such thing as a casual "real programmer". there are only real programmers who have lost their anchor in daily life.

ok the easiest way of thinking of it is like this
Int - whole number (no decimal (1,2,-5,0))
Double and float can be kinda tricky but really just comes down the level of precision for the decimal point.

Both are literally just decimal numbers but the main difference is the resolution, floats are 32 bit numbers while double is a 64 bit number. The tricky thing is that 32 is smaller than 64 bit so by definition a float can be a double but a double can't be a float (lost-precision error)

Jesus son I program for a living, everyone starts somewhere

Alright whatever I'm just trying to get past a class bro not making a whole fucking life out of it, maybe if your brain could process what you're looking at correctly you'd see that I already said this.

So I have this so far I think I need to change the private int to a private float then?
public class Rectangle {

private int rectangle;
private int length;
private int width;
private int perimeter;
private int area;

public Rectangle( float length, float width){

if(length < 0.0 || length >= 20.0){
throw new IllegalArgumentException("Length must be between 0.0 and 20.0.");
}
if(width < 0.0 || length >= 20.0){
throw new IllegalArgumentException("Width must be between 0.0 and 20.0.");
}
this.length = (int) length;
this.width = (int) width;

Op this guy is right but went a little overboard. You can program casualty.

you would have to change them to floats given that your object constructor is expecting floats

Ok cool I'll start from there thanks for the help at least someone is willing to help out.

Why not just use this:
double height = 4;
double base = 15;
System.out.println((base*height)/2);

Floats overkill for this? why not just stick with double?

I mean he could change floats into doubles but just out of professional habit (mainly because I work in embedded development) I tend to just use floats because of the 32 bit size

you can do a lot of things casually.

where OP is right now is nowhere. only like 10% of the people that start computer science--where OP is--ever actually make it into the actual major. it's extremely exclusive and there's no "affirmative action"; grades speak for themselves.

i know how fucking hard it is. discrete math and unix/C programming are the hardest. most universities demand a B in discrete math and that's VERY hard to get because it's like 600 topics and sucks ass. unix/C is fucking grueling. you are told at the beginning that you will probably fail to really get the grade you need to get in to the major and... that's what happens.

once i got in, i feel like some kind of blessed motherfucker but it only gets more complicated. i know however, that it was the hardest thing i ever did in my life and i finally got in at age 40. i worked very hard and it blew my mind.

i'm telling you now... you will never even get in to the major unless you do this crap yourself and you need more than basic working java... you need to know the hierarchy and structure like a master because intermediate java will kill you. people get As on homework--"i got it working 100%" jerk off crap--and fail midterms and go crazy.

i know how it is. they don't want retards in the major.

"And my orders are to weed out all non-hackers who do not pack the gear to serve in my beloved Corps." - Full Metal Jacket

Ok so how is this looking?

public class Rectangle {

private float rectangle;
private float length;
private float width;
private float perimeter;
private float area;

public Rectangle( float length, float width){

if(length < 0.0 || length >= 20.0){
throw new IllegalArgumentException("Length must be between 0.0 and 20.0.");
}
if(width < 0.0 || length >= 20.0){
throw new IllegalArgumentException("Width must be between 0.0 and 20.0.");
}
this.length = length;
this.width = width;
}
public float getLength(){
return length;
}
public float getWidth(){
return width;
}
public void setPerimeter(){
perimeter = ((getLength()*2) + (getWidth()*2));
}
public float getPerimeter(){
return perimeter;
}
public void setArea(float area){
area = getLength()* getWidth();
}
public float area(){
return area;
}
}

I am using NetBeans to write this in too if that offers any help to an explanation.

See my major is in IT of game design so there is a little bit of programming yes, but its not a big part of my major. Its more of an animation / 3d modeling major, but I mean this is good info to know I'm glad its offered.

mmm I should just break out my IDE but lazy, your setArea is confusing me a bit as to why you are passing in an argument and your setPerimeter you are not

Man idk, I should just leave that blank right?
I'm trying to follow the example in my book but the book is not doing the exact same thing.

you are correct, question is do you know why it is correct?

I completely understand where you are coming from considering I went through the same path and conjunction did a lot of electrical work too (computer engineer) but with programming a person needs to understand how to work with the basics before understanding more in depth theory such as stacks/heaps/graphs/pointers/etc

Just don't take it for granted that we have moved beyond OP by many fold and forget that somewhere we had to start to learn what OP is learning. I have worked with a lot of great people who believe it or not struggled with the basics but in the end because they struggled with the basics and questioned things had a much more intimate understanding walking out then people who breezed through it the first time

Because it would mess it up somehow. I already put float area underneath it too so it would duplicate the command right?

generous user not only helping but teaching

Hey I'm thankful for it, it's better than rereading my book over and over trying to figure it out.

When you create a new Rectangle Object lets say

Rectangle rec1 = new Rectangle(2,2);
//filler code
rec1.setArea(/*you would have to put something here but yet you can't*/);

That and also your area would have a conflict of instances (global vs local which is something you should of learned about). In short your setArea is already calling getLength() and getWidth() so you wouldn't need to pass anything in there already

>I had some shit come up and I got a week behind
I had to hide from my weed dealer.

"conflict of instances" should really be identifying the "scope" of the variable. Global vs Local, kinda happens when you switch between so many different languages that the vocabulary slips once in a while

okay that makes sense. I think I forgot to default the length and width to 1 so would I just put
private float length = 1;

lol nah I work at Disney World and it is really busy this time of year as you can imagine.

Yea it is always good practice to "initialize" your variables (fancy way of setting the default values when you create the object)

Also user you in the Orlando area?

So when I'm creating the test class for this do I just make a new file and as long as its in the same package as the Rectangle.java it should be fine right? That's where I was having a problem because the book says to compile them but that's if you were using notepad like they are I believe.

yeah kind of in Poinciana near Kissimmee

mmm ok that is outside the scope of programming per say but I can break down that comment.

Everything you write in java needs to be compiled just due to how java works (technical discussion which I love having). The reason everything in Java needs to be compiled is because of how portable the code needs to be. Java's gimmick is that you write the program and compile it on any system (has to do with the code be translated into a binary form that the processor needs to understand but that is WAY outside the scope of what the book is trying to say)

Secondly the test class would be in a separate file in most cases where you don't have a main declared. Basically main is a reserved keyword that the compiler understands to run immediately when the program starts up. You seem to have main in the same file as Rectangle which is legal. (1/2)

Live actually north side of Orlando

OP, I suspect your lecturer is going to be expecting you to be around controlling access to members of a class also (consider what methods need to be accessed externally from the class and which do not). This may help you: docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

(2/2)

Now in the real world we would separate Rectangle and all it's relating functions in a separate file to make big projects manageable (hundreds of objects and classes and the last thing we want to do is go digging through nonrelated files trying to find a function that is not related to the rest of the file. In extreme cases everything in one file would be literal hell.

In short you separate main from everything else and use this as the 'driver' to drive the rest of your process flow and the other files to support the logic of making the code work. If you separate the two files you would need to link them together but telling main "YO HOOK UP WITH DAT RECTANGLE CLASS BBY" by telling main to "import" the class. This is done by directory so best thing to do is keep the all the files in the same directory for the simplicity of learning.

Oh wow you're not that far away, and so even though I'm using netbeans I should still compile them? I did a quick test file just to see if it would work and this happens.

that makes sense so the directory would just be where everything is setup to be stored right? Or is that something I make myself?

Correct, where everything is setup (in this case where your source files are at (.java))

Now you see something not right with your getPerimeter? It isn't returning the right values, this is because you aren't assigning them when you are creating the object

So I should be setting them up in the first program? Or in that empty space there in the test file? Sorry if I seem retarded I'm just really tired.

java sucks ass for anything useful in 2018 so just write some useless shit. You don't need help for writhing useless shit OP.

repaste your rectangle class

wait repaste it where in the test file?
and am I repasting the whole thing ?

yeah that's real helpful info but this is for a class I have no choice but to learn it.

I mean repaste your rectangle class here so I can review it once again, there is something I don't see as to why it isn't working

Can you issue external libs?

ah lol sorry here you go.

What you are learning is OO concepts which translate between languages.

Persist with this guy's advice, he is actually attempting to teach rather than giving you the answer.

O I am a dumbass, I am tired as well. Obviously it is returning 0 because we haven't ran "setPerimeter" to actually generate a perimeter to be stored :/

right before you printf write 'rectangle.setPerimeter()', that should work

Bingo!

awwwwwww yeah it finally works. I really appreciate your help with this, now I only have 3 more to go lol hopefully I'll get them done.

forgot the pic

I still have to add that weird menu option thing but I think I know how to do that I just import the JOption pane and ask for input and then throw some if and then statements in there right?

Glad to see it working!

And more or less that is exactly what you have to do. In your main you read the inputs from the dialog box and then you follow the same logic of passing what the user entered into the constructor you wrote

ok I think I'm gonna work on that later after some sleep. Hopefully you'll be browsing again if I post anymore questions I thank you for your help.

No problem user, glad I could help and hope you well

This looks suspiciously like some of the java assignments at my college in Nebraska