ICS 32A Fall 2019
Project #0A: The Morning After the Night Before

Due date and time: Wednesday, October 2, 11:59pm

This project is to be done individually


One of the core assumptions of this course is that you've taken an introductory programming course in some programming language before, but that the language was something other than Python. For some of you, it may have been a while since you last wrote a program, so a good way to hit the ground running this quarter is to flex the muscles you built previously, by solving some small-scale problems in a language that you're already familiar with. Of course, not all of you have the same background, so we'll allow you to choose any language you prefer for this task, with the only caveat being that it cannot be Python.

The problems

This project consists of eight problems that you'll be asked to solve. Choose one programming language with which to solve them; you are not permitted to use different languages for different problems. There are no rules about what you can choose, except that the language can't be Python; examples of languages you could choose include Java, C++, C, JavaScript, Ruby, C#, Visual Basic, Scheme, Racket, or Haskell, though you're certainly not limited only to those choices. Use what you're familiar with and, as long as you avoid Python, anything goes.

For each problem, write a single function, method, procedure, subroutine, etc., that can be called to solve it. (Different programming languages name this particular concept differently, but they basically all have something like it.) You can feel free to define additional helpers that assist in the solution to each, but the problems are small enough that they don't necessarily need them. Make clear, though, using comments or naming conventions, which parts of your submission solve which problems, so we can quickly determine which ones you've attempted.

You'll notice that the problems are defined a little bit loosely in some cases, mainly because we're allowing enough flexibility here — since you can choose any programming language other than Python — that we can't nail them down any more carefully than this. The goal, in general, is to consider the spirit of each problem, not to stress too much about the tiny details of how they're worded. None of the problems is intended to be a trick, and each is intended to flex a particular muscle that you will have likely built previously, and are definitely going to need again in this course. Avoid pre-built solutions (e.g., functions or methods you would find in a standard library like the one included with Java or C++) that solve the problem simply by calling the solution that exists; the point of this exercise is to be sure that you're able to solve these problems on your own from first principles. (Again, keep in mind the spirit of what we're doing here; this is to make sure you're back in the swing of things before you work on new material in Python.)

Problem 1

Given two numbers, representing the width and the height of a right triangle, calculate the perimeter of the triangle (i.e., the sum of the lengths of all three of its sides).

Problem 2

Given two strings of text, calculate their concatenation and return it as a separate string of text. The concatenation of two strings is a string that contains all of the characters in the first string, followed by all of the characters in the second. For example, the concatenation of boo and lean is boolean.

(Whenever these problems refer to a "string of text," I'm referring to a sequence of individual characters. Choose an implementation that is appropriate for the language you chose. For example, in Java, you would use a String; in C++, you might use a std::string or a char*; and so on.)

Problem 3

Separately read two pieces of input from a user, which are intended to be both a name and an age (in years). Afterward, print the output Your name is XXX and you are YYY years old, where XXX is the name and YYY is the number of years old. So, for example, if the name was given as Boo and the age was given as 11, you would print Your name is Boo and you are 11 years old. Note, too, that you should finish that sentence with 1 year old instead of 1 years old if the age is 1.

(Whenever these problems refer to reading input from a user, you'll need to handle that in a way that is appropriate for the language you chose. For example, in Java, you might use a Scanner; in C++, you might use std::cin; in C, you might use scanf; and so on.)

Problem 4

Given a list of numbers, compute its sum.

(Whenever these problems refer to a "list", I'm referring to a sequence that may have an arbitrary number of values in it. Choose an implementation that is appropriate for the language you chose. For example, in Java, you might use an ArrayList or an array; in C++, you might use a std::vector or an array; and so on.)

Problem 5

Given a list containing strings of text, determine the longest string (i.e., the string that contains the largest number of characters).

Problem 6

Read input from a user that is intended to consist of a license number (such as a driver's license number). If the input is not a valid license number, then ask again, and continue asking until the input is valid.

We'll say, for the purposes of this problem, that a license number must follow these rules in order to be valid:

By these rules, the following are all valid license numbers: A123B, ABC1DEF, A1B2C3D4E. These would all be invalid: A123, 123B, ABCDEF, A1B2C3D4.

Problem 7

Given a string of text and a character to search for, count the number of times that the search character occurs in that string. For example, in the string Boo is not boolean, the search character o appears five times, while the search character b appears once (because upper- and lowercase are considered distinct).

Problem 8

Given a string of text, determine whether it is a palindrome. A palindrome is text that consists of letters that would look the same whether you printed them in order or in reverse order. So, for example, HANNAH is a palindrome, but HELLO HELLO is not.

How we will grade your submission

Unlike other projects, this project will be graded on a 2-point scale, with the 2 points being allocated completely to whether or not you submitted an honest attempt at each of the problems above. Since there are eight problems, we'll allocate 0.25 points to each of them, with no partial credit available (or, really, necessary; either it's an honest attempt or it's not).

With the wide variety of possible submissions, since we're allowing you to use any programming language you'd like, we'll be looking at your solutions but not thoroughly testing them. Honest attempts will be accepted even if not entirely correct. Note that this is quite different from how we'll be grading most of your work in this course, but given that the goal here is to get warmed up, we'll cast a less scrutinizing eye on this one.


Follow this link for a discussion of how to submit your project via Checkmate. Be aware that I'll be holding you to all of the rules specified in that document, including the one that says that you're responsible for submitting the version of the project that you want graded. We won't regrade a project simply because you submitted the wrong version accidentally.

What to submit

Submit only your source code, but no additional files generated by any kind of development environment — project files, build scripts, or the like. For example, if you wrote your solutions in Java, a single .java file will suffice.

Can I submit after the deadline?

This project is not included in the late work policy for this course. The objective is not just that you do this one, but that you do it early enough to be of benefit, so it needs to be completed during the initial days of the course and submitted before the due date above. Submissions beyond that deadline will not be considered.

The late work policy for this course — which does not apply to this project, but applies to all of the others — is described in the section titled Late work at this link.

Should I submit if I'm not enrolled yet?

If you're on the waitlist for the course and intending to enroll if given the chance, you'll still need to submit this project on time. You can register yourself in Checkmate even if you're not enrolled in the course. Follow this link for a discussion of how to submit your project via Checkmate.