CISK 332 115/515 Java Programming

advertisement
CIS 332—Summer 2013
Texas A&M University Central Texas
CIS 332-110 Java Programming
M-W 4:45 – 7:15 pm
INSTRUCTOR AND CONTACT INFORMATION
Instructor:
Office:
Phone:
Email:
Office Hours:
Dr. Timothy G. Woodcock
323G - Founders Hall
254-519-5783
WoodcockTG@ct.tamus.edu
TWR – 1-3:30 PM and by appointment
Course Overview and description:
This course is geared to upper-division students and covers more topics at a faster pace than the lower-level
course. It provides an in-depth study of the Java programming language and how it implements the
principles underlying object-oriented modularity through successive focusing on structured programming
theory, functional abstraction, data encapsulation, and software module design. The course significantly
expands the coverage beyond the fundamentals by introducing and applying systematic methodologies for
isolating and correcting logic errors using debugging tools commonly found in the software industry.
Course Objective:
Understand and master syntax and features of the Java Programming Language
 Built-in data types, variables and constants – declaration, initialization, and assignment
 Expressions; math, relational and logic operators
 Interactive input and Graphical User Interfaces
 Simple file operations and streams
 Java syntax for program structures – sequence, decision, loop
 Using Java class libraries
 Creating Java methods and classes
 Creating Arrays and strings
 Exceptions and exception handling
Apply principles of program design and logic
 Structured programming use sequence, decision, and loops
 Functional abstraction
 Modular design using Java methods
 Class design incorporating all of the principles listed above
Apply principles of program logic to isolate errors
 Debuggers included with the Integrated Development Environment
 Setting breakpoints and watch variables
 Using output to report program progress
Required Reading and Textbook(s):
“Starting out with Java”, Tony Gaddis, Addison-Wesley
Note - A student of this institution is not under any obligation to purchase a textbook from a universityaffiliated bookstore.
CIS 332—Summer 2013
Course Requirements:
There will be two exams, a midterm exam worth 100 points, and a final exam worth 100 points.
There will be 8 programming assignments worth 100 points each. Assignments will be graded based on the
following rubric: 1) that the software works and does the job specified in the assignment (40%), 2)
demonstrates the concepts being covered (30%), and 3) contains the appropriate documentation
(comments)(30%).
1.
Project #1: Introductory Program. Demonstrate the use of variables. Write a program that asks the user to enter the
following information: 1) Verb, 2) Adjective, 3) Plural Noun, 4) Adjective, 5) Verb ending in “ing”, 6) Verb, 7)
Number, 8) Adjective, 9) Plural Noun, 10) Plural Noun, 11) Plural Noun, 12) Type of Relative, 13) Adjective, 14)
Adjective, and 15) Plural Noun. As the user enters these values, the program should save the values in appropriately
named variables. After the user has finished the program should display the following story with the user’s input in
the appropriate locations: “Come <#1> at WALMART, where you`ll receive <#2> discounts on all of your
favorite brand name <#3>. Our <#4> and <#5> associates are there to <#6> you <#7> hours a day. Here you
will find <#8> prices on the <#9> you need. <#10> for the moms, <#11> for the kids and all the latest
electronics for the <#12>. So come on down to your <#13> <#14> WALMART where the <#15> come first.”
2.
Project #2: Demonstrate the use of decisions. Given the fact that there are 12 inches in a foot, and 5280 feet in a
mile, and one eighth of a mile in a furlong, compute the distance for a selected unit of feet, miles, or furlongs for a
given number of inches. Write a program that prompts the user for “feet”, “miles”, or “furlongs”. Then the program
should prompt the user for a distance in inches. Lastly, the program should compute the number of feet, miles, or
furlongs for the given number of inches and display this amount with the units selected.
3.
Project #3: Demonstrate the use of loops. Write a program to calculate a hotel’s occupancy rate. The Occupancy
rate = # of rooms occupied / total # of rooms. You should use loops to validate all input. Your program should start
by prompting the user for the number of floors. Validate that the number of floors must be at least 1 and no more
than 10. Your program should iterate once for each floor. For each floor, the program should ask for the number of
rooms and then the number of occupied rooms. Validate the input making sure that there are at least 10 rooms on a
floor and that the number of occupied rooms is less than the number of rooms on a floor. Display the total number
of rooms in the hotel, the number of occupied rooms, the number of un-occupied rooms, and the occupancy rate for
the hotel.
4.
Project #4: Demonstrate creating and using methods. Create a program that plays the rock, paper, scissors game
between the user and the computer. Create a method to compute the computer’s choice (use a random number
between 1 and 3). Prompt the user for their choice. Have a method to decide who wins (rock beats scissor, scissor
beats paper, paper beats rock, and two the same is a tie). Repeat the game until exit is chosen, then display the
number of games played, how many games the computer won, how many games the user won, and how many
games were ties (use a method to compute this). Your program MUST have at least four methods in it.
5.
Project #5: Demonstrate arrays. Write a program that inputs a series of positive integers between 0 and 20, that uses
an array to count how many times each integer is input. Do NOT save the integers that are input. Save the count of
the integers that are input. When the input is an integer that is out of range (<0 or >20), the program should, for
every integer whose count is greater than zero, display the integer and the count of the number of times this integer
was input.
6.
Project #6: Demonstrate classes. Create a class to store and manipulate Roman numerals. For simplicity, we will
use simplified Roman Numerals where 3 = III, 4 = IIII, 5 = V, 6 = VI, 7 = VII, 8 = VIII, 9 = VIII,…, 19 = XVIIII,
etc. Your class should store the Roman numeral as a Roman numeral and as the equivalent decimal number. The
following table shows the decimal equivalent of Roman numerals:
CIS 332—Summer 2013
Roman Numeral
Decimal
M
D
C
L
X
V
I
1000
500
100
50
10
5
1
Your class, let’s call it Roman, should have the following methods:

Constructor: Accepts a Roman numeral only, saving the numeral and computes and saves the decimal
equivalent of the Roman numeral.

PrintRoman: Prints the Roman numeral

GetRoman: Returns the Roman Numeral stored in the class.

GetDecimal: Returns the decimal stored in the class.

AddRoman: Accepts as parameter an object of type Roman and returns an object of type Roman that is
contains the sum of the class Roman numeral and the parameter Roman numeral. (Hint: you will need a method
to convert a decimal to a Roman numeral.)

SubRoman: Same as above but subtracts.
Include a program to create objects of type Roman and demonstrate add and subtract.
7.
Project #7: Demonstrate basic GUI’s. Write a program with a GUI interface that allows a user to play a simple
game of Hi-Low. This game is played by having the computer generate a hidden number between 1 and 100. The
user guesses the number and the computer checks the hidden number against the guess and tells the user if the guess
was high or low. The round continues until the user guesses the number. The game continues as long as the user
wants to continue.
8.
Project #8: Demonstrate string manipulation. Write a program that encrypts and decrypts plaintext into a secret
code. For our code we will use a simple Row transposition cipher. To encrypt a message we need two things a
message and a code key, which in this case is a series of integers. For example, let’s say our message is “I want an
A in this class” and the code key is 516243. We start by creating a 2D array and putting the message in the arrayone
letter at a time, across the rows as shown below (use * for blank space).
5
I
*
I
S
S
1
*
A
N
*
*
6
W
N
*
C
*
2
A
*
T
L
*
4
N
A
H
A
*
3
T
*
I
S
*
Then we reorder the columns in the array so that the code key is in numerical order and read the columns to get the
encrypted message.
1
*
A
N
*
*
2
A
*
T
L
*
3
T
*
I
S
*
4
N
A
H
A
*
Encrypted message: *AN** A*TL* T*IS* NAHA* I*ISS WN*C*
5
I
*
I
S
S
6
W
N
*
C
*
CIS 332—Summer 2013
Note 1: The code key can only contain the column number once and every column number must be in the code key.
Note 2: Do not ever use this code for any real application. Third graders with an I-phone can crack this code in less
than 5 minutes.
Grading Criteria Rubric and Conversion
Assignment
Mid-term Exam
Final Exam
Projects
Total Points
100
100
800
Complete Course Calendar
Date
6/5/2013
6/10/2013
6/12/2013
6/17/2013
6/19/2013
6/24/2013
6/26/2013
7/1/2013
7/3/2013
7/8/2013
7/10/2013
7/15/2013
7/17/2013
7/22/2013
7/24/2013
7/26/2013
Topic
Introduction
Variables
If statements
While Loop
For Loop
Methods
Arrays
Midterm Exam
Classes/Objects
More Classes
ArrayList Class
File I/O
GUI
String Class
Final Exam
Grades must be
submitted to
Registrar by
4:00PM
Assignments
Project 1
Project 2
Project 3
Project 4
Project 5
Project 6
Project 7
Project 8
Grade
A
B
C
D
F
Points
900-1000
800-899
700-799
600-699
Below 600
CIS 332—Summer 2013
Drop Policy
If you discover that you need to drop this class, you must go to the Records Office and ask for the
necessary paperwork. Professors cannot drop students; this is always the responsibility of the student.
The record’s office will provide a deadline for which the form must be returned, completed and signed.
Once you return the signed form to the records office and wait 24 hours, you must go into Duck Trax and
confirm that you are no longer enrolled. If you are still enrolled FOLLOW-UP with the records office
immediately. You are to attend class until the procedure is complete to avoid penalty for absence. Should
you miss the deadline or fail to follow the procedure, you will receive an F in the course.
Academic Integrity Statement
Texas A&M University - Central Texas expects all students to maintain high standards of personal and
scholarly conduct. Students found responsible of academic dishonesty are subject to disciplinary action.
Academic dishonesty includes, but is not limited to, cheating on an examination or other academic work,
plagiarism, collusion, and the abuse of resource materials. The faculty member is responsible for
initiating action for each case of academic dishonesty and report the incident to the Director of Student
Affairs. More information can be found at www.ct.tamus.edu/StudentConduct.
Disability Support and Access
Texas A&M University – Central Texas complies with Section 504 of the Rehabilitation Act of 1973 and
the Americans with Disabilities Act of 1990. TAMUCT promotes the use of the Principles of Universal
Design to ensure that course design and activities are accessible to the greatest extent possible. Students
who require reasonable accommodations based on the impact of a disability should contact Gail Johnson,
Disability Support Coordinator at (254) 501-5831 in Student Affairs, Office 114E. The Disability Support
Coordinator is responsible for reviewing documentation provided by students requesting
accommodations, determining eligibility for accommodations, helping students request and use
accommodations, and coordinating accommodations.
Tutoring
Tutoring is available to all TAMUCT students, both on-campus and online. Subjects tutored include
Accounting, Finance, Statistics, Mathematics, and Writing (APA). Tutors are available at the Tutoring
Center in Founder's Hall, Room 204, and also in the Library in the North Building.
Visit www.ct.tamus.edu/AcademicSupport and click "Tutoring Support" for tutor schedules and contact
info. If you have questions, need to schedule a tutoring session, or if you're interested in becoming a
tutor, contact Academic Support Programs at 254-501-5830 or by emailing
cecilia.morales@ct.tamus.edu.
Chat live with a tutor 24/7 for almost any subject on your computer! Tutor.com is an online tutoring
platform that enables TAMU-CT students to log-in and receive FREE online tutoring and writing support.
This tool provides tutoring in Mathematics, Writing, Career Writing, Chemistry, Physics, Biology,
Spanish, Calculus, and Statistics. To access Tutor.com, click on www.tutor.com/tamuct.
Library Services
INFORMATION LITERACY focuses on research skills which prepare individuals to live and work in an
information-centered society. Librarians will work with students in the development of critical reasoning,
ethical use of information, and the appropriate use of secondary research techniques. Help may include,
yet is not limited to: exploration of information resources such as library collections and services,
identification of subject databases and scholarly journals, and execution of effective search strategies.
CIS 332—Summer 2013
Library Resources are outlined and accessed at. http://www.tarleton.edu/centraltexas/departments/library/
UNILERT
Emergency Warning System for Texas A&M University – Central Texas
UNILERT is an emergency notification service that gives Texas A&M University-Central Texas the
ability to communicate health and safety emergency information quickly via email and text message. By
enrolling in UNILERT, university officials can quickly pass on safety-related information, regardless of
your location. Please enroll today at http://TAMUCT.org/UNILERT
INSTRUCTOR POLICIES
Students should come to class prepared, ready to ask questions and participate in discussions.
While in other classes, the direct quoting of other authors is considered acceptable; in this class, it is not
acceptable. You may not directly quote any other published paper, web site, or textbook in any writing
assignment, including papers, homework, discussion boards, PowerPoint presentations, or any other
written assignments. The simple reason for this is that copying (quoting) is a lower level skill. However,
reading, understanding, and then communicating the ideas in your own words is a high level skill, which
is the skill that I want you to develop.
Dr. Woodcock reserves the right to modify this syllabus during the semester.
Instructor Information
Dr. Woodcock has a PhD in Computer Science from Florida Atlantic University. He has over 25 years of
real world experience working for IBM and Sony-Ericsson. Dr. Woodcock believes that you will learn
best by being engaged in class, asking questions, participating in discussion, and doing the hands on
exercises.
This class will be a lot of work, but it will also be fun.
Download