INTRODUCTORY PRACTICE PROBLEMS – LEVEL SUB-JUNIOR

 

ABOUT THESE PROBLEMS

 

These are introductory programs to get you acquainted with the problems that you will encounter on the CCC.  Note that these problems are easier than the actual CCC problems.

 

ABOUT SAMPLE I/O

 

In the examples below, orange Sample I/O signifies user inputted information while the black info is outputted by the program.  Notice that with minimalist I/O, the program never displays a message to inform the user to input the numbers.

 

 

PROBLEM #1 (A + B)

 

Jimmy TwoShoes needs to write a program that will get and simply add two integers that are provided to him using minimal I/O.

 

SAMPLE I/O #1

4

8

12

SAMPLE I/O #2

22

11

33

 

PROBLEM #2 (A + B BUT N TIMES)

 

Jimmy TwoShoes needs to write a program that will first get the number of additions N that his program will need to do.  Then, the input provide will include N lines with two numbers.  For each line, the program needs to add up the two numbers and output their sum.

 

SAMPLE I/O #1

3

6 4

2 9

1 4

10

11

5

SAMPLE I/O #2

1

-11 3

-8

SAMPLE I/O #3

4

2 0

9 1

12 7

102 48

2

10

19

150

 

PROBLEM #3 (AVERAGE)

 

Jimmy TwoShoes needs to write a program that gets the value N from the user.  Then, on the same line N numbers appear.  The program must output the average value of the N numbers.

 

SAMPLE I/O #1

3 10 15 20

15.0

SAMPLE I/O #2

1 8

8.0

SAMPLE I/O #3

5 1 3 3 4 2 

2.6

SAMPLE I/O #4

4 2 2 2 2

2.0

 

 

PROBLEM #4 (WORD LENGTH)

 

Jimmy TwoShoes needs to write a program that first gets the value of N from the user.  Then, on N different lines, a word will be inputted.  The program must determine how many words are exactly 3 characters in length and output that amount to screen.

 

SAMPLE I/O #1

3

milk

cat

post

1

 

SAMPLE I/O #2

7

Mouse

Dog

Jimmy

Hat

Yoyo

Three

Tap

3

SAMPLE I/O #3

3

Go

Habs

Go

0

 

 

Warning to Java users: Scanner doesn’t play well with two types of data input.  You may wish to read everything as a String here.