CSci 2101 Problem set 1. Java data types, conditionals.

Due Friday, January 27th at 11:59pm (by e-mail)

15 points

A helpful resource for problems 2 and 3 is Java String API.

Problem 1 (6 points)

Write a program that declares three integers (n1, n2, and n3) and then print them in order (the smallest one first). Make sure that your program works for all possible initial orderings. Assume that all three integers are different. Write down in comments what data you used to test your program.

Problem 2 (5 points)

Write a program that declares an integer n and a string and prints the substring of the string that is n characters long. If n is larger than the length of the string, the entire string is printed. If n is negative or 0, an empty string is printed. Here are some examples:

Problem 3 (4 points)

Write a program that declares a string and a character (as Java type char) and prints "Yes" if the string contains the character and "No" if it doesn't.

How to submit

Submit your Java file(s) to me by e-mail. The subject must be Problem Set N, where N is the problem set number.


CSci 2101 course web site.