CS 113 Fall 2014
Due Date: See Syllabus
Name & UCID & Section Number: Please write your name, UCID, and section number on the submission – please staple together – no loose sheets
What is to be submitted?
1. Problem 1: Answers to the exercises
2. Problem 2: Program listing with the program output using the input in file Data3.txt and user interaction based on the input you have entered.
1. Exercises (25 points)
a) (20 points) Show the syntax (form) , explain its meaning, and give an example of each of
i. while loop, ii. for loop, iii. if statement, iv. array (give an example declaration and its use), and
v. boolean type
b) (5 points) What does a break statement do when executed inside a loop?
2. Directory1 Lookup Application (75 points)
What is the assignment?
Write a directory (database) lookup application which operates by
1. reading a list of numbers stored in file Data3.txt to create a database of numbers:
1
The word directory is used here as it use in "telephone" directory or a "store" directory" as opposed to its use in
"file" directory which refers to the organization of files in a computer system such as Unix or Linux.
CS 113 Fall 2013 – Assignment 3
1/4
•
•
The list of numbers is preceded by a number (first number in the list) that specifies the size of the list.
This file name Data3.txt is supplied as a command-line argument to the application. 2. accepting user input (supplied at the keyboard) which are numbers that it checks to see whether or not they are in its database.
For each number x input by the user the program displays (prints) “x is in the list” or
“x is not in the list” depending upon whether or not x is in the list.
The program terminates when the user enters Ctrl-Z (Ctrl-D) on the keyboard.
Input File Data3.txt
14
21
222
210
-44
78
88
96
0
-1
88
7890
567
999
-101
The list has 14 values as indicated by the first value in the file.
Sample user interaction (submit your version of the user interaction)