| Help Non-Retro Uprising Questions. Programming help, tech support, self help, advice, the meaning of life - it goes here. |
|
10-15-2014, 09:52 PM
|
#1
|
|
|
Java HW ;_;
Since my textbook is useless and doesn't help me learn, I've come to my fellow nerds to help me with some Java code.
Problem 1
Problem 2
I've gotten pretty much everything else so far, but I've been stuck on these two problems (and two others) for an hour so far. I'm probably overthinking it/tired, but I want to get my work done.
|
My Signature |
|
"My mind is my weapon. My brother has his sword, King Robert has his warhammer and I have my mind... and a mind needs books as a sword needs a whetstone if it is to keep its edge. That’s why I read so much, Jon Snow."
10-15-2014, 10:12 PM
|
#2
|
|
|
Re: Java HW ;_;
I'd fail this class right away.
|
My Signature |
|
10-15-2014, 10:17 PM
|
#3
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by Tails
I'd fail this class right away.
|
So far I've done pretty well. I have assignments in this eBook, but most of the time it does a bad job at explaining the topic. So it's trial and error until I get it right.
|
My Signature |
|
"My mind is my weapon. My brother has his sword, King Robert has his warhammer and I have my mind... and a mind needs books as a sword needs a whetstone if it is to keep its edge. That’s why I read so much, Jon Snow."
10-15-2014, 11:28 PM
|
#5
|
|
|
Re: Java HW ;_;
Problem 1:
I already tried that. It passes the first test, but the system's second test fails it.
Problem 2:
Second one says the "==" is an error, reason being "incomparable types: char and java.lang.String"
This eBook is annoying. I feel like it works so differently than Eclipse.
---------- Post added at 12:28 AM ---------- Previous post was at 12:26 AM ----------
This things not due until Monday and I'm pretty tired (got class early tomorrow) so I gotta crash. I'll check back her tomorrow afternoon when I get home.
|
My Signature |
|
"My mind is my weapon. My brother has his sword, King Robert has his warhammer and I have my mind... and a mind needs books as a sword needs a whetstone if it is to keep its edge. That’s why I read so much, Jon Snow."
10-16-2014, 11:55 AM
|
#6
|
|
|
Re: Java HW ;_;
Problem 1:
Your code is different. See bolded.
My test:
Code:
for(int i = 0; i < 3; i++)
{
char c = passCode.charAt(i);
if(c.isDigit())
hasDigit = true;
}
Your test:
Code:
for(int i = 0; i < 3; i++)
{
char c = passCode.charAt(i);
if(Character.isDigit(i))
hasDigit = true;
}
You are not testing the character c, you are calling the isDigit(int codePoint) function from the Character class and passing it the current loop index as the parameter. This is completely different from what you want to do.
Problem 2:
Replace the " " (quotation marks) with ' ' (apostrophes).
---------- Post added at 12:55 PM ---------- Previous post was at 01:14 AM ----------
Ok so never code late at night...mine was wrong. Yours was correct but you were still passing the array index instead of the character itself.
Problem 1:
Quote:
Originally Posted by Seahawk
Problem 2:
Replace the " " (quotation marks) with ' ' (apostrophes).
|
Alternatively, use the isWhitespace(char ch) function.
|
|
|
10-16-2014, 05:43 PM
|
#7
|
|
|
Re: Java HW ;_;
Thanks for the help Seahawk, both are right now.
I was close on the first one, needed the 'c' instead of the 'i'
And second one was an easier fix, just needed to replace the " " with ' '
---------- Post added at 06:43 PM ---------- Previous post was at 04:52 PM ----------
Quote:
Write a for loop in Java that prints the integer values from 1 through n, counting by inc. For example,
if n is 25 and inc is 5, the loop will print the sequence
1
6
11
16
21
Your code should work for any positive values of n and inc. You may assume that the integer variables
n and inc have already been declared and assigned values. Just write the code for the loop!
|
Any help with this one? I know what the question is asking me, I just don't know how to get the counter to work/stop.
|
My Signature |
|
"My mind is my weapon. My brother has his sword, King Robert has his warhammer and I have my mind... and a mind needs books as a sword needs a whetstone if it is to keep its edge. That’s why I read so much, Jon Snow."
10-16-2014, 06:05 PM
|
#9
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by Kong
|
Doh! I had the right answer, I just set n and inc to 0 in Java when they were supposed to be fixed values. Setting them to actual values makes it work xD
Thanks though, for some reason reading your post helped me realize my mistake.
|
My Signature |
|
"My mind is my weapon. My brother has his sword, King Robert has his warhammer and I have my mind... and a mind needs books as a sword needs a whetstone if it is to keep its edge. That’s why I read so much, Jon Snow."
10-16-2014, 07:09 PM
|
#10
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by CrispyChicken
Thanks though, for some reason reading your post helped me realize my mistake.
|
Having a buddy look over your stuff is very beneficial in coding.....but only one person at a time, not more. Three or more way coding never works.
Kong is right, the important part is you learn what happened here, this is why I put code in spoilers.
Just curious, do you plan to continue programming classes after this class?
|
|
|
10-16-2014, 07:12 PM
|
#11
|
|
|
Re: Java HW ;_;
Ahh, Java. That takes me back. A shame I don't really remember any of it. 
|
My Signature |
|
10-16-2014, 07:14 PM
|
#12
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by Seahawk
Having a buddy look over your stuff is very beneficial in coding.....but only one person at a time, not more. Three or more way coding never works.
|
Three way coding?
Quote:
|
Originally Posted by SH
Just curious, do you plan to continue programming classes after this class?
|
Yep, computer science is my major. Not sure specifically what I want to do but pretty sure it'll be programming related.
|
My Signature |
|
"My mind is my weapon. My brother has his sword, King Robert has his warhammer and I have my mind... and a mind needs books as a sword needs a whetstone if it is to keep its edge. That’s why I read so much, Jon Snow."
10-16-2014, 08:08 PM
|
#13
|
|
|
Re: Java HW ;_;
Nearly all of the coding jobs have been outsourced to India. You'll need to really creative, lucky, or find another line of work.
|
My Signature |
|
10-16-2014, 09:51 PM
|
#14
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by Kugyince
Nearly all of the coding jobs have been outsourced to India. You'll need to really creative, lucky, or find another line of work.
|
Or be damn good.
|
My Signature |
|
kong on Bronies:
"Of the 75% that are straight I would bet at least 10% would rather have a cheeseburger than a girlfriend."
10-17-2014, 08:37 AM
|
#15
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by stevencassidy13
Or be damn good.
|
According to my CS friends, no you really don't. As in everything else, it's more who you know not what you know. The stories they tell of people who can't code anything at all but still have coding jobs are insane.
They also say good coding jobs are hard to find. You'll either work for a massive company like Google who will put you under ridiculous deadlines and demands(which is why they offer so much at their HQ, they don't want you to leave the office) or you'll be a contractor where you are employed by one company who will farm you out to other companies on a contact basis.
Last edited by bearhawk72; 10-17-2014 at 08:42 AM..
|
|
|
10-17-2014, 12:23 PM
|
#16
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by stevencassidy13
Or be damn good.
|
I think that falls under creative if it's even a factor at all.
|
My Signature |
|
10-17-2014, 03:35 PM
|
#17
|
|
|
Re: Java HW ;_;
I figured creative meant in how you land the job. I really don't know jack about it, but I just kind of assumed it would be like anything else, the cream rises to the top...
|
My Signature |
|
kong on Bronies:
"Of the 75% that are straight I would bet at least 10% would rather have a cheeseburger than a girlfriend."
10-17-2014, 03:49 PM
|
#18
|
|
|
Re: Java HW ;_;
Guys all he wanted was homework help.
|
|
|
10-17-2014, 06:23 PM
|
#19
|
|
|
Re: Java HW ;_;
Conversation naturally flows and evolves. His questions were answered so why not lead the thread into something interesting? Better than just another dead thread.
|
My Signature |
|
10-17-2014, 06:37 PM
|
#20
|
|
|
Re: Java HW ;_;
Well this won't be the last time I'll be using this thread. I'm sure I'll be stuck on a lot of problems in the future.
Last edited by CrispyChicken; 10-17-2014 at 06:58 PM..
|
My Signature |
|
"My mind is my weapon. My brother has his sword, King Robert has his warhammer and I have my mind... and a mind needs books as a sword needs a whetstone if it is to keep its edge. That’s why I read so much, Jon Snow."
10-17-2014, 06:52 PM
|
#21
|
|
|
Re: Java HW ;_;
Exactly, and we're already covering the inevitable I can't find a job problem preemptivly! Remember, it's all about efficiency when dealing with code.
|
My Signature |
|
kong on Bronies:
"Of the 75% that are straight I would bet at least 10% would rather have a cheeseburger than a girlfriend."
10-17-2014, 06:59 PM
|
#22
|
|
|
Re: Java HW ;_;
It's ok, I got that Pro Tying Speed 
|
My Signature |
|
"My mind is my weapon. My brother has his sword, King Robert has his warhammer and I have my mind... and a mind needs books as a sword needs a whetstone if it is to keep its edge. That’s why I read so much, Jon Snow."
10-17-2014, 07:14 PM
|
#23
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by CrispyChicken
It's ok, I got that Pro Tying Speed 
|
Great, that will help you fill out unemployment and welfare documents that much faster.
|
My Signature |
|
10-17-2014, 10:00 PM
|
#24
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by stevencassidy13
I figured creative meant in how you land the job.
|
My first real job was at Microsoft. I was 20, a high school dropout and the only computer I'd ever used was an old Atari ST. I failed the interview but then just followed all of the new hires (the guys that passed their interview) and pretended like I was with them. No one ever noticed I wasn't supposed to be. First thing I did was ask the guy next to me how to send an email. I set a record in my department for most promotions in first year. When I quit I was in charge of 200 people. During one interview for a promotion HR asked what I did to prepare for the interview. I said I bought a new suit and a haircut. She said I got the promotion mostly because of that answer; it showed I didn't need to cram for the technical part of the interview. Reality, the interviewer just didn't know enough to ask any technical questions.
I think that proves that HR must have been very creative when getting their jobs. They weren't qualified to interview anyone. It was dotcom bubble though. No one was qualified for anything they were doing back then.
While I was working for MS I applied at ID. They turned down in the first 2 minutes of the interview because I wore a tie and short sleeve shirt. They said MS boys were too stuffy and ID was a tshirt and jean company. MS was super casual too, but still you dress up for an interview. ~1999.
|
My Signature |
|
10-17-2014, 10:37 PM
|
#25
|
|
|
Re: Java HW ;_;
Quote:
Originally Posted by Kong
My first real job was at Microsoft. I was 20, a high school dropout and the only computer I'd ever used was an old Atari ST. I failed the interview but then just followed all of the new hires (the guys that passed their interview) and pretended like I was with them. No one ever noticed I wasn't supposed to be. First thing I did was ask the guy next to me how to send an email. I set a record in my department for most promotions in first year. When I quit I was in charge of 200 people. During one interview for a promotion HR asked what I did to prepare for the interview. I said I bought a new suit and a haircut. She said I got the promotion mostly because of that answer; it showed I didn't need to cram for the technical part of the interview. Reality, the interviewer just didn't know enough to ask any technical questions.
I think that proves that HR must have been very creative when getting their jobs. They weren't qualified to interview anyone. It was dotcom bubble though. No one was qualified for anything they were doing back then.
While I was working for MS I applied at ID. They turned down in the first 2 minutes of the interview because I wore a tie and short sleeve shirt. They said MS boys were too stuffy and ID was a tshirt and jean company. MS was super casual too, but still you dress up for an interview. ~1999.
|
That's friggin awesome, reminds me of the time my entire department was getting canned. They asked all of us to go down to a room for an emergency meeting. I had suspected that something was up so I didn't go. When the IT guy came around to log everyone out of their computers for the last time,(to prevent mass deletion in a fit of rage) he saw me still sitting there, I told him I was told not too attend the meeting. I was moved to a new department, and promptly got a promotion, -witch I can't explain. Not quite as epic as your story Kong, but in the same vein so I figured I'd share.
|
My Signature |
|
kong on Bronies:
"Of the 75% that are straight I would bet at least 10% would rather have a cheeseburger than a girlfriend."
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:22 AM.
|