Open Side Menu Go to the Top

09-19-2014 , 06:03 PM
Quote:
Originally Posted by Barrin6
one of our hw assignments is to watch the Matrix and find words that are tech related.
loooool, wow
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
09-19-2014 , 06:42 PM
ok so i made a program that is suppossed to show the highest score and the second highest score. it works but the output doesnt show the actual second highest score. what did i do wrong?

Spoiler:
import java.util.Scanner;

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

// Prompt the user to enter the number of students
System.out.print(
"Enter the number of students: ");
int numOfStudents = input.nextInt();

System.out.print(
"Enter a student name: ");
String student1 = input.next();
String student2 = student1;
System.out.print(
"Enter a student score: ");
double score1 = input.nextDouble();
double score2 = 1;
double score3 =0;
double tempscore = 4;

for (int i = 0; i < numOfStudents - 1; i++) {
System.out.print(
"Enter a student name: ");
String student = input.next();

System.out.print(
"Enter a student score: ");
double score = input.nextDouble();


if (score > score1) {
student1 = student;
score1 = score;
}
else if (score < score1){
score3 = score;
tempscore = score3;
if (tempscore > score3 && tempscore < score1)
tempscore = score2;
student2 = student;
}
}

System.out.println("Top student " +
student1 + "'s score is " + score1);
System.out.println("Second place student " +
student2 + "'s score is " + score2);
}
}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-19-2014 , 06:45 PM
also i wrote a tuition program and was wondering about two specific things:

Spoiler:
double tuition = 10000; //year 0
int year = 0;
while (year <= 9){
tuition = tuition * 1.05;
year++;
}
double cost = tuition + (tuition * 1.05) + (tuition * 1.05 * 1.05) + (tuition * 1.05 * 1.05 * 1.05);
System.out.println("tuition will be $" + tuition + " in " + year + " years");
System.out.println("The total cost of tuition in 10 years is: $" + cost);


1.) what is the better ways to do the calculution"double cost = tuition + (tuition * 1.05) + (tuition * 1.05 * 1.05) + (tuition * 1.05 * 1.05 * 1.05);" hpw do i shorten it
2. how do io convert output to two decimal places so it looks like actual dollars?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-19-2014 , 08:47 PM
For the first one, what does it show as the second score?

For the second one, if this was c++ I could help you in a heartbeat. Maybe google java format two decimals or something similar

Also, code tags might work better than spoilers for longer bits of code

Code:
 like this:

[ code ]
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-19-2014 , 08:56 PM
Quote:
Originally Posted by spaceman Bryce
ok so i made a program that is suppossed to show the highest score and the second highest score. it works but the output doesnt show the actual second highest score. what did i do wrong?
Look at what you do when you get a new highest score. Think about what should happen and then trace exactly what you're doing.

There may be other problems in there, but this is one place to start.

Edit: And nitpick, but 'running' isn't the same as 'working'.

Edit2: There are other problems. Take a step back from your code and think about all the cases that can happen when you get a new score. Make sure you understand those cases without thinking about code at all. Once you've got that figured out, try to write code that does what you want. Draw boxes if you need to, to represent the values of score, score1, score2, and score3.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-19-2014 , 09:01 PM
I'm confused why there are 3 constant questions about Python in that assignment.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-19-2014 , 09:59 PM
Bryce, i showed you how to format decimals earlier, did you not read it and just copy paste the code i wrote?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 04:03 AM
Quote:
Originally Posted by spaceman Bryce
ok so i made a program that is suppossed to show the highest score and the second highest score. it works but the output doesnt show the actual second highest score. what did i do wrong?
score2 is never set after initialization.

You're also making a couple of logical mistakes in your if/else clause comparing scores.
E.g. the "if (tempscore > score3 && tempscore < score1)" part in your "else if (score < score1)" block will never be triggered. tempscore will always be equal to score3 due to the assignments done before that check - and tempscore will always be less than score1 in that context.
I also don't like that you're not catching the case when the entered score is equal to the best score. It just skips over both if and else blocks.

An easier way to do it is something like this:
If the entered score is better than the best score, move the best score to second best, and set the best score to the entered one.
If it is not better than the best score but better than the second best score, replace the second best score with the entered score.

If you explicitly want to ignore equal scores (such as we have 3 scores 10, 10 and 9, and the output should be best: 10, 2nd best: 9), you'll have to adapt the checking logic to discard equal scores from comparison. I doubt that you intend to do that, though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 12:05 PM
so I'm writing this really irritating program that's supposed to strip C style comments from code using cin as the input stream

here's what I have:

Code:
void strip()
{
	char ch;
	bool erase = true;

	string str = "";

	while (cin.get(ch))
	{
		
		if (ch == '"')
		{
                        // flag so that I don't delete comments inside quotations
			erase = false; 
			cin.unget(); // go back one to include the quotation mark

			do
			{

				str += ch;
				cin.get(ch);
			} while (ch != '"'); // end loop when second quote is found

		}

		else if (ch == '/' && cin.peek() == '*' && erase)
		{
			cin.unget();
			do
			{
				cin.get(ch);
				if (ch == '*' && cin.peek() == '/')
				{
					goto h; 
				}


			} while (cin);
			h: cin.get(ch);

		}


		else if (ch == '/' && cin.peek() == '/' && erase)
		{
                        // skip over everything until you reach a nextline char
			while (cin && ch != '\n')
				cin.get(ch);

			cin.unget(); // so i don't skip over the nextline character
		}
		else
			str += ch; // add the char to the output string


	}
	cout << str;
}
it works perfectly unless you input something like ""string s = \"\\\"hello\\\"\"; /* cmt1 */ string s2 = \"bye\"; /* cmt2 */",

it won't delete the /* */ comments, obviously because I didn't reset the erase flag. but everywhere I try to reset it, it ****s something up. Logically it should reset after the do/while loop ends, right? but when I do that, it will start deleting comments inside quotations again.

I hate flags, tried to write this without it, and i know the above is really sloppy, but if someone could point me in the right direction I'd be stoked.


edit: damn, already got it to work right after I posted that but it's sooooo ****ing ugly.

instead of

Code:
if (ch == '"')
		{
                        // flag so that I don't delete comments inside quotations
			erase = false; 
			cin.unget(); // go back one to include the quotation mark

			do
			{

				str += ch;
				cin.get(ch);
			} while (ch != '"'); // end loop when second quote is found

		}
the unget() was the culprit, all that block was doing was setting the erase flag to false and not executing any of the other ****. So i removed that and reset the flag after loop - except then it wasn't including the last set of quotation marks. so after the loop I added an extra quotation to the string.

I know there's a better way to do this, ugh

Last edited by jmakin; 09-20-2014 at 12:23 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 03:47 PM
jmakinmecrzy,

Wtf we are in the same class? I turned in that assignment already. I am 99% positive we are in the same class now.

Either way you have to really break down the strip() function into multiple functions or else you will have a complete mess. It will make the assignment much more difficult than it is.

Divide and conquer is the key.

PM me or hit me up on the C++ freenode if you want some help

Last edited by Barrin6; 09-20-2014 at 03:53 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 03:59 PM
Redacted

I got it to work its just really ugly

Separate functions would be prettier but im not rewriting it. The second assignment took me literally 3 minutes

Last edited by jmakin; 09-20-2014 at 04:12 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 04:03 PM
Yes lol. I would edit that out though so no one can google
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 04:12 PM
Haha, weird. M/W 11:10 AM for me.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 04:18 PM
Yea I am in the Tuesday/Thursday night section. Having a difficult time working full time and taking 3 classes with C++ and the online calc class taking the most my time.

Word of advice from my friend who took our class, prepare yourself for vectors & pointers,because that's when a lot of people start struggling if they haven't already.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 04:44 PM
I did a lot of similar stuff in java already, luckily. My schedule is similar. I think the proff is sort of a prick sometimes.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 05:13 PM
Quote:
Originally Posted by Barrin6
My python class is such a joke.
What answers did you give and what are the correct answers?

I get the sense you could anything and every answer is either correct or wrong.

Quote:
Bill is at more than 30 years old. Write a program that that will solve this problem and,

Graph your answer.


???
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 05:31 PM
That legit cracked me up. And the way the problem is phrased
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 05:31 PM
Quote:
Originally Posted by jmakinmecrzy
I did a lot of similar stuff in java already, luckily. My schedule is similar. I think the proff is sort of a prick sometimes.
Haha I think he's quite hilarious. His sarcasm can rub people the wrong way.

Quote:
Originally Posted by daveT
What answers did you give and what are the correct answers?

I get the sense you could anything and every answer is either correct or wrong.

lol great graph. By graph, she meant to do a flowchart.

But yea, we haven't got our homework back yet. Which I'm not sure if the professor even checks the previous assignments.

For a professor who keeps harping on how programmers spends a lot time on design and requirements, the homework sure as hell are vague.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 06:13 PM
You should find a way to argue that red pill is tech related. Also that Carrie-Anne Moss is too, since her boobs may be made of silicon (yes, spell it wrong for emphasis)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 07:07 PM
Quote:
Originally Posted by jjshabado
Look at what you do when you get a new highest score. Think about what should happen and then trace exactly what you're doing.

There may be other problems in there, but this is one place to start.

Edit: And nitpick, but 'running' isn't the same as 'working'.

Edit2: There are other problems. Take a step back from your code and think about all the cases that can happen when you get a new score. Make sure you understand those cases without thinking about code at all. Once you've got that figured out, try to write code that does what you want. Draw boxes if you need to, to represent the values of score, score1, score2, and score3.
Quote:
Originally Posted by jmakinmecrzy
Bryce, i showed you how to format decimals earlier, did you not read it and just copy paste the code i wrote?
I know but when you showed me how to format decimal places it was to a different decimal place, and when i tried to change the number it didnt work.
Im sorry but I don't have a logic intense background and am trying to learn things so it will take me more time to figure out things than a lot of the people on here at first. i spent the last 9 years working at a grocery store and drinking a lot and stuff- When it comes to math or computer science i currently dont know much of anything . I know im not going to be the next super genius who makes a robot friend who can sing songs in the shower and help you shop for lamps but maybe i can make money being a web developer or making a phone ap whihc would be way better than working at the grocery store.

I only bring up the last paragraph for jmakin and because i really appreciate the help you should just know where im coming from.Thanks
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 07:42 PM
Haha no worries dude. Always glad to help
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 08:13 PM
I've been a bit more aggressive about getting into the tech industry.

Seems like the standard sequence is to:
- Talk to the main recruiter to get an idea of the job, the scope, see if I'm a jerk, etc.
- Arrange a time to talk to a hiring manger, often the manager I'd be working under.
- Go in for a real interview.

The other day, the guy on the phone said that he was going to put me in for mid-level, "possibly senior," due to my qualifications and experience. Other departments focus on junior level, but that probably won't be my cup-of-tea.

Uh... what? I didn't exactly express concern here, but I don't know why I'd be considered for this.

This isn't the first time this happened. I had one reply from a [legit] company about my resume and the team leader offered to interview me for senior / lead developer based on my "qualifications and experience." I responded that I'm probably not their guy, is there something more, oh idk, junior available?

I wrote a pretty good resume, but there is nothing cooked and certainly nothing misleading. I just describe my roles, the tools and languages I use, link to my github, and that's it. Education is left blank.

Question:

I suppose asking "What is going on here?" would give me a bit of insight into... well, what is going on, but the more practical consideration is:

How do I respond when I'm pretty sure the job I'm being considered for is above my head? For the extreme example, I know I should say "no thanks" and leave it at that since its a waste of everyone's time, but for the minor up-step, I'm assuming that I will be expected to have more knowledge than the average junior developer, and I have no idea how to prepare for this or what to expect. How quickly am I setting myself up to lose face at the whiteboard? If I managed to get a job like this, how quickly do I expect to be fired?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 08:23 PM
Quote:
Originally Posted by daveT
How do I respond when I'm pretty sure the job I'm being considered for is above my head? For the extreme example, I know I should say "no thanks" and leave it at that since its a waste of everyone's time, but for the minor up-step, I'm assuming that I will be expected to have more knowledge than the average junior developer, and I have no idea how to prepare for this or what to expect. How quickly am I setting myself up to lose face at the whiteboard? If I managed to get a job like this, how quickly do I expect to be fired?
I think the correct answer is to talk about how you have a lot of experience with the non-technical things like managing people, working with people, getting **** done, whatever specific things you have a lot of experience doing that translate well across positions. Talk about how you would have no problem with this aspect of a senior position.

But then mention that you're worried that since you don't yet have many years of technical experience you're looking for a role where you can get some of that technical experience before taking a senior role. And that you're excited to work for a place where you know you can learn those skills and still have lots of opportunities for advancement.

I wouldn't worry about losing face at the whiteboard. I mean, who cares if you fail, right? Some day I'll talk about how I once blew an interview that was worth many multiples of my current net worth...

I would worry about not setting expectations properly if you get hired for a role though - so I think you need to stress that your experience right now isn't that technical.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 08:44 PM
Agree with jjshabado.

Tell them you are honoured but why you are hesitant. Another good angle (which I always use in my interviews) is asking which aspects of the job they expect you to struggle most so you can prepare for that.

Don't worry about losing face at the whiteboard. If you are embarrassing yourself there, it clearly isn't the right job for you. And there's nothing wrong about that. Can't be the perfect solution for every position out there.

I cannot fathom a capable, friendly person able to learn and close the gaps quickly ever being fired in such a position. Unless you run into a last-in, first-out situation.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-20-2014 , 08:51 PM
Quote:
Originally Posted by kazana
I cannot fathom a capable, friendly person able to learn and close the gaps quickly ever being fired in such a position. Unless you run into a last-in, first-out situation.
I once had to fire someone like that - nice guy, relatively fast learner, but way over his head for the position he had. Sometimes you're hiring a senior person for a senior role and there's not enough time to ramp up on the position/project and technology.

The other issue is even if you're not fired it can cause a lot of friction with peers/subordinates.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m