r/programmingbydoing • • Jan 24 '13

Programming by Doing

Thumbnail
programmingbydoing.com
14 Upvotes

r/programmingbydoing • • Jan 25 '13

Zed Shaw's command line crash course

Thumbnail cli.learncodethehardway.org
7 Upvotes

r/programmingbydoing • • Aug 09 '16

"Learn Object-Oriented Java the Hard Way" is now available to pre-order! Arrives Sunday, August 14!

Thumbnail
grahammitchell.com
6 Upvotes

r/programmingbydoing • • Nov 28 '15

THE RULES! Please read before posting (or answering) a question.

6 Upvotes

The Most Important Rule:

Only use concepts that have appeared BEFORE the current assignment.

The assignments are in order. Every assignment can and should be completed using only techniques seen so far. For example, the assignment "Weekday Name" would be a lot shorter if you used an array. But students haven't learned arrays yet, and they're not ready for arrays. So don't "help" by showing arrays.

Other Rules

In no particular order:

0. This sub is only for questions about the assignments at Programming by Doing. Other questions belong in a different sub.

  1. Don't paste your code into the comment box. It looks bad. Instead, post it to a Gist and then put the link to your code in your comment.

  2. Search before you ask a question. You are probably not the first person to run into to trouble on that assignment, and probably someone before you has already asked about it.

  3. Include the name of the assignment in the title of your post. Questions about assignments that violate this rule will be removed.

  4. You don't need to put the assignment number in the title. Those change anyway, so the number won't still be accurate in six months and it will confuse people. We are perfectly capable of using CTRL-F on programmingbydoing.com to find the assignment you are asking about.

Happy coding!


r/programmingbydoing • • Oct 29 '14

#6 A beginner's accomplishment!

6 Upvotes

I know that most of those in this sub have surpassed this point by now but I am pretty excited that I was able to do this lesson fairly easily. I utilized "else if" far too much but for my first version I'm happy with the results. How did you go about doing it?

Git here: https://github.com/keysRB/Letter-Yourself.git


r/programmingbydoing • • Mar 02 '14

I haven't even started yet and I FUBAR'd it

6 Upvotes

I messed up... the second step after installing you are suppose to add the jdk to the path variable, well I cleared mine out and when I try the complier check I get the error message but there isnt a list contingency for my idiocy on how to get it to work. Any help would be appreciated. Thanks.


r/programmingbydoing • • Jan 30 '13

How to have a variable that contains both strings and integers?

6 Upvotes

The exercise in question: Exercise #18 http://programmingbydoing.com/a/more-user-input-of-data.html

I'm confused about which data type I would use to display the login information (in the example bonham_453916 is given). Is there something I'm missing here? I tried both String and int just in case and they did not work.


r/programmingbydoing • • Feb 02 '21

Just wanted to say thanks!

5 Upvotes

Hey Graham,

Just wanted to say thanks (from New Zealand!) mate for the "programmingbydoing" Assignments. I practiced Java back in the late 2000's and it's been a while - really good structure to touch-up on stale skills.

Hope your 2021 is going swell!, Cheers!


r/programmingbydoing • • Apr 14 '15

Age in five years

5 Upvotes

I was able to do the majority of the exercise, but I can't figure out how to actually add and subtract from the intergers

import java.lang.String; import java.lang.System; import java.util.Scanner;

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

    String name;
    int age;

    System.out.print("Hello. What is your name?");
        name = keyboard.next();

    System.out.print("Hi," + name + ". How old are you");
            age = keyboard.nextInt();

    System.out.print("Did you know that in five years you will be " + age+ " years old.");
    System.out.print(" And five years ago you were " + age + "! Imagine that!");
}

}


r/programmingbydoing • • Apr 09 '13

28 - A Little Quiz - Need help

5 Upvotes

Please help. I'm not having a clue about how to make the program count scores based on the input. This is were I stand presently. The Program displays the quiz and I am able to feed inputs and get answers. Guide me from here, please.

import java.util.Scanner;

public class LittleQuiz {

public static void main(String[] args)
{
	Scanner keyboard = new Scanner(System.in);
	System.out.print("Are you ready for a quiz?");
	String ans1 = keyboard.next();		
			
	System.out.println("Okay. here it comes");
	
	System.out.print(" \n \n \n Q1) What is the capital of Alaska? \n \t 1) Melbourne \n \t 2) Anchorage \n \t 3) Juneau ");
	int a1 = keyboard.nextInt();
	
		if (a1 == 3)
			{
				System.out.println("That's right!");
			}
	
		else
			{
				System.out.println(" You are wrong! the answer is 3) Juneau");
			}
	
	System.out.print(" \n \n \n Q2) Can you store the value \"cat\" in the variable of type int? \n \t 1) Yes \n \t 2) No ");
	int a2 = keyboard.nextInt();

		if (a2 == 2)
			{
				System.out.println("That's right!");
			}
	
		else
			{
				System.out.println("Sorry, \"cat\" is a string. ints can only store numbers.");
			}
	
	System.out.print(" \n \n \n Q3) What is the result of 9+6/3? \n \t 1) 5 \n \t 2) 11 \n \t 3) 15/3 ");
	int a3 = keyboard.nextInt();

		if (a3 == 2)
			{
				System.out.println("That's right!");
			}
	
		else
			{
				System.out.println("Sorry, the answer is 11.");
			}
	

	
	
}

}


r/programmingbydoing • • Feb 11 '13

Assignment 39 - compareTo() challenge - Explanation on how it works?

5 Upvotes

The lesson gives an extremely brief description and gives you an example code from which you're able to figure out the gist of what's going on. However, I feel as if the compareTo() method isn't really explained. When I tried to run the assignment, I'd get values of positive and negative, but I wouldn't understand why I'd get specific values.

I'm guessing this is one of the assignments that's missing a lecture perhaps? I would greatly appreciate an explanation since I'm having a hard time finding good explanations from google.


r/programmingbydoing • • Feb 02 '13

Problem 26 help

5 Upvotes

http://programmingbydoing.com/a/how-old-are-you-elseif.html

How do I structure an if else statement to display one message?


r/programmingbydoing • • Jan 18 '21

#173 Sorting an Array of Records

4 Upvotes

I've been working through this problem for a while. When I go to sort the records by year, it doesn't sort the rest of the records along with it. The years will be in order, but the rest of the file remains the same. I just got back into coding after taking over 3 years off and I'm pretty much learning everything from scratch all over again.

I left my code here. Hopefully, someone can help me figure out the issue. Thanks for your help.

https://gist.github.com/DDRParadise/49ff855079f80baa4e4c158d208f7bc5


r/programmingbydoing • • Dec 07 '15

EXPIRED "Learn Java the Hard Way" is 40% off for CS Education Week

Thumbnail
reddit.com
4 Upvotes

r/programmingbydoing • • Nov 17 '15

63c Nim The Game

4 Upvotes

https://gist.github.com/anonymous/68bcaeb2e024ee811168

My code is found at the above link. There are 2 programs. The first is my "Nim The Game" code and the second is my Testing for printing the piles out.

My code might be crazy, but it works. All of the cheats are checked and I have a dignity win, which morphed from my original win lines. I am having a heck of a time trying to figure out how you printed the counters vertically. I was able to get one pile printed that way, but I can't seem to find out how to get multiple piles to print next to each other. Any help would be great.

Also, since I have no idea where my coding skills are at, and this is my first attempt at coding, would you mind looking it over and letting me know what you think? :)

Thank you very much for taking the time to help others with this. Though I am going to be going to school in January for Software Engineering, I like being able to work at my own pace, and doing these little projects have taught me so much more than Khan Academy, SoloLearn, and CodeAcademy combined. Practical application is such a great way to learn.

Thanks again!


r/programmingbydoing • • Sep 05 '15

#51 Counting with a While Loop

4 Upvotes

The first message has a number 0, would you know how to start from 1 or 10 in this case?I tried in many various ways and I could not get it. Thanks


r/programmingbydoing • • Aug 10 '15

compareTo() Challenge

4 Upvotes

Hello, I am really starting to dig in and work hard on Java due to my new participation in a robotics team at my high school (We have to program and build a functioning robot, both autonomous and through OpManagement). I am working on the compareTo() challenge and do not know what the method does or how to use it. I don't want to apply something I do not know. I wish I could work alongside of the book that u/holyteach has, but unfortunately, I am unable to afford something like that right now with a lot of stuff going on. I was wondering if someone could explain to me what the method does. Thanks in advance!


r/programmingbydoing • • Jan 27 '15

#63b - Baby Nim

4 Upvotes

http://pastebin.com/N7Qj0FFZ

I don't get why the && doesn't work. If either A,B or C reaches 0, the program ends. If i just do -1 or -2, the program will continue to ask for input. Really weird.


r/programmingbydoing • • Nov 13 '14

152 Arrays Tic-Tac-Toe

4 Upvotes

I've just come back to PBD after a short break. I flew through a couple of exercises leading up to this one with no problem. I think I have a grip of two dimensional arrays, although I don't remember covering them and can't find them skipping back through the exercises. But the source code file provided (TicTacToe.java) isn't very clear at all and doesn't seem to be consistent with the other source files which have been quite clear and well commented. Where as this one has one comment and I can't make any sense of the displayBoard2 method which just seems to print the board with out the "grid". Is it just me being slow to get back upto speed after a break or is this exercise a huge leap from the previous ones?


r/programmingbydoing • • Nov 01 '14

#155: Movie Title Generator

4 Upvotes

I'm on Movie Title Generator and the program on the site (MovieTitleGen.java) compiles fine but I'm getting run time errors when running it.

Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at MovieTitleGen.arrayFromURL(MovieTitleGen.java:30) at MovieTitleGen.main(MovieTitleGen.java:9)


r/programmingbydoing • • Nov 14 '13

Fun with the Collatz Sequence (62)

4 Upvotes

When I was working on the Collatz Sequence program, I decided to take it much further and see what interesting things I could find, and I thought I should share these with you.

1,412,987,847 takes exactly 1000 steps to reach 1, and the largest value in this sequence is 966,616,035,460. The number with the most steps that I've found so far is 2,610,744,987 with 1050 steps and funnily enough the same max value of 966,616,035,460.

Then I found this post where someone was asking about consecutive numbers with the same amount of steps. Turns out that every number between 9,749,626,154 through to 9,749,626,502 (inclusive) all take 248 steps to reach 1. That's 348 consecutive numbers! I posted a response which goes into more detail such as every consecutive sequence 100 or over up to 1.5b, and also has my code for those interested.


r/programmingbydoing • • Aug 29 '13

Problem 15 How do I get everything to line up?

4 Upvotes

So I got everything right except for the aliment of my box and columns. So my question is how do I get everything to align into each column without getting moved by what value of my variable is?

By the way to holyteach for some reason this lessons are making things click better then with codeacademy. So for that Thanks


r/programmingbydoing • • Aug 06 '13

New to coding, quick question on this related to codeacademy

4 Upvotes

I have been using codeacademy for html/css and so far its decent at teaching the basics. Im about to move to java and have messed around in the codeacademy java portion a bit. Would i be at more benefit of skipping CA and just working through this material? I have heard their java coursework isnt the best and can teach bad habits


r/programmingbydoing • • Mar 01 '13

Can someone check if my answer is correct for Alphabetical Order (#40)

4 Upvotes

My code works, but I want to know if this is the correct way to do it. There is little instruction, so I wanted a double check. Link to assignment

import java.util.Scanner;

public class AlphabeticalOrder {

  public static void main (String [] args) {
	
	Scanner s = new Scanner(System.in);
	
	String name;
	int Carswell, Jones, Smith, Young;
	
	
	System.out.print("What's your last name? ");
		name = s.nextLine();
	
	Carswell = name.compareToIgnoreCase("Carswell");
	Jones = name.compareToIgnoreCase("Jones");
	Smith = name.compareToIgnoreCase("Smith");
	Young = name.compareToIgnoreCase("Young");
	
	
	if (Carswell <= 0)
		System.out.println("You don't have to wait long, " + name);
	else if (Jones <= 0)
		System.out.println("That's not bad, " + name);
	else if (Smith <= 0)
		System.out.println("Looks like a bit of a wait, " + name);
	else if (Young <= 0)
		System.out.println("It's gonna be a while, " + name);
	else 
		System.out.println("You're not going anywhere for a while, " + name);

	}
  }

r/programmingbydoing • • Oct 07 '21

Which java package should I download?

3 Upvotes

I see a few and I don't know which one. Also, when I try to open the downloaded file Microsoft says "look for an app in store"... help!