CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the...
Transcript of CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the...
![Page 1: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/1.jpg)
CSC116: Introduction to Computing - Java
![Page 2: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/2.jpg)
Intro to CSC116
Course Information
• Introductions
• Website
• Syllabus
Computers
First Java Program
• Text Editor
• Helpful Commands
• Java Download
![Page 3: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/3.jpg)
Instructors• Course Instructor:
– Mrs. Michelle Glatz, [email protected]
• Office: Daniels 223
• Office Hours:
– OnLine: Sundays 9-10pm
– On-Campus: Tuesdays 5-6 pm in Daniels 200
– By appointment – set up via email
• Support email: [email protected]
• TA:
– Rui Shu, [email protected]
•Online Office Hours: Fridays 7-9 pm
![Page 4: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/4.jpg)
Office Hours• On-Line Office Hours: Dedicated time to
answering questions via Piazza, email, or Google Hangout
• CSC116 On-campus Office Hours:
– http://go.ncsu.edu/csc116teachingstaffofficehours
– We use My Digital Hand during on-campus office hours to manage questions:
• http://mydigitalhand.org
![Page 5: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/5.jpg)
Textbook• Building Java Programs
A Back to Basics Approach4th EditionReges and Stepp
• NCSU CSC Department, Style Guidelines
![Page 6: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/6.jpg)
Course WebsiteEngineering Online course homepage:
Links to:
– Syllabus
– Video Lectures
– Moodle page
Moodle login page:
• http://wolfware.ncsu.edu
• Moodle Course Page (direct link)
– course materials– submit coursework– feedback returned– grade book
![Page 7: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/7.jpg)
Moodle • Syllabus Link
– Syllabus
• Schedule Link
– Schedule
– All Lab-Exercises are due on Sunday night
Including those designated as in-class exercises.
•Assignments due at 11:45 pm
![Page 8: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/8.jpg)
Course Structure
• The course structure is a mixture of lecturing and practicing as we go through material.
• The idea is to reinforce the learning of new material with hands on experience using it right away.
![Page 9: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/9.jpg)
Exercises• In-class: Meant to be completed while watching
the lecture. Due Weekly.
• Lab: Apply new concepts. Due Weekly.
• Practice-It! Exercises: Every 2 chapters turn in list of problems solved as Homework (screenshot pdf: cntrl-P, capture your userid)– https://practiceit.cs.washington.edu/
– create an account
– choose a problem from list
– Type a solution and submit it.
– The system will test it and tell you whether your solution is correct.
![Page 10: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/10.jpg)
Programming Assignments
• There will be 6 programming projects in addition to the Lecture Exercises.
• MUST BE DONE INDIVIDUALLY!!
![Page 11: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/11.jpg)
Academic Integrity
• Do your own work (projects)
– Don’t copy from outside resources (don’t google it!)
– Don’t look at other student’s code
– Don’t show your code to another student
• See syllabus for violation penalties
![Page 12: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/12.jpg)
Exams
• Two midterm exams
• One final exam
• Check the course schedule on our website for dates. You will have a 2-day exam window.– Schedule a time with your proctor at any time during
this window.
• Paper exams, closed book, closed notes, closed computer.
![Page 13: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/13.jpg)
Message Board• The course message board (Piazza) is a
great place to ask questions and discuss topics with the Instructor, TAs, and all the other students in class– piazza link
• The only rule is that you may not publicly post any code that directly comes from an assignment, but example code is permitted
• Make the question private if need to post your code.
• Post to Group 601 if specific to our section
![Page 14: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/14.jpg)
Grading• Minimum Grade Requirement
➢ Need a 73 to advance to CSC216➢To earn a C- or higher you must:
•have an exam average of at least 60AND
•have a project average of at least 60Activity Weight
Exercises:(.2 * In-class avg + .6 * Weekly Exercise avg + .2 * Practice-it! avg)
14
Projects 30
Comprehensive Exercise 2
Exam 1 17
Exam 2 17
Final Exam 20
![Page 15: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/15.jpg)
Regrade Requests
• The TA’s will send out an email to inform you when they have completed grading of each assignment.
• To request a regrade (within one week):➢ Send an email to the Teaching Staff support email
with Regrade Request as the subject line.
➢ Include the name of the assignment and why you think it should be regraded.
![Page 16: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/16.jpg)
What you will learn in CSC116…
• Problem solving – the purpose of writing a program is to solve a problem
• Java programming language
• Concepts of Object-Oriented Programming (OOP) – encapsulated collection of data variables and methods
• Documentation techniques
• Testing methods
![Page 17: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/17.jpg)
Hardware
• The physical components that make up a computer:
– CPU (Central Processing Unit)
•Executes program instructions (brains)
– Memory (RAM)
•Used to store current program and data
– Hard Disk
• Permanent data storage
![Page 18: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/18.jpg)
Software
• Computer programs
• Operating System
• Bridge between hardware, programs, user
• Allocates memory and send instructions to CPU
• Applications
• Programs run within the operating system
![Page 19: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/19.jpg)
Binary and Decimal
• Typically, we (humans) use the base-10 (decimal) notation.
– Uses the digits 0 through 9
• All information is stored on a computer as binary numbers– 1’s and 0’s (base 2)
– 10 (1 * 21 + 0 * 20) = 2 base-10
– 11 (1 * 21 + 1 * 20) = 3 base-10
– 100 (1 * 22 + 0 * 21 + 0 * 20) = 4 base-10
![Page 20: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/20.jpg)
Binary and Decimal
• Binary (Base-2)
• Decimal (Base-10)
24 23 22 21 20
16 8 4 2 1
104 103 102 101 100
10,000 1,000 100 10 1
![Page 21: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/21.jpg)
Convert between Decimal and Binary
• 20 Decimal to Binary (20 – 16 = 4, 4 – 4 = 0)
• 1 1 1 0 0 Binary to Decimal
16 + 8 + 4 + 0 + 0 = 28
24 23 22 21 20
1 1 1 0 0
16 8 4 0 0
![Page 22: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/22.jpg)
Bits and Bytes
• Bit – Binary Digit
• Byte – 8 Bits
• Kilobyte (KB) 210 – 1024 bytes
• Megabyte (MB) 220 – 1,048,576 bytes
• Gigabyte (GB) 230 – 1,073,741,824 bytes
![Page 23: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/23.jpg)
Programming Languages• We can write a program using only 0s and 1s, but that
has many disadvantages
– Hard to look at and understand
– Very tedious!
• We use a programming language instead - we write code in English instead of 0s and 1s, which is much easier to read and understand
• The code we write is interpreted by a program called a compiler, which translates our English into 0s and 1s for the processor to understand
• Java is the programming language we will use in this course
![Page 24: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/24.jpg)
Computer Programming
• Algorithm - A step‐by-step description of how to accomplish a task.
• Program – A list of instructions to be carried out by a computer.
• Computer Programming – the art of designing and writing a group of instructions that the computer’s processor executes.
![Page 25: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/25.jpg)
Software• You may download the Java 2 Standard Edition (J2SE) Software
Development Kit (JDK) from http://www.oracle.com/technetwork/java/javase/downloads/index.html
– Download JDK version 8u191, DO NOT download version 11.
• Text Editor• Mac
• TextWrangler, Aquamacs
• Windows• Notepad++
• Configure to convert tabs to 4 spaces :– Notepad++ : Settings->Preference->Language
Set Tab size to 4 Check Replace by space box
- TextWrangler : Preferences->Editor Defaults->Auto-expand tabsSet tabs to 4 spacesrestart TextWrangler for
changes to take place
![Page 26: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/26.jpg)
Java Download for Laptop
• The next set of slides show the java download and set up process.
• The current version on the download site is Version 11.– We will be using version 8
• The java version used for demonstration is version 8 update 152 (current version is 191)
• http://www.oracle.com/technetwork/java/javase/downloads/index.html
![Page 27: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/27.jpg)
Download JavaCurrent Download is Version 11, don’t download this one.
![Page 28: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/28.jpg)
Download JavaPage down to the following Version 8 downloads. Click
on the JDK download
![Page 29: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/29.jpg)
Accept Agreement
![Page 30: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/30.jpg)
Installation• Save the file to the desktop and run it• Install to default location
The installation screen should read (don't change it):
Install to:C:\Program Files\Java\jdk1.8.0_152\
![Page 31: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/31.jpg)
Installation
![Page 32: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/32.jpg)
Install Directory
![Page 33: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/33.jpg)
Setting the Path – Windows• Once the installer is finished, you must set your computer's path
before Java will work correctly – FOR WINDOWS ONLY
➢Go to the Control Panel and double-click System
➢ Select the Advanced tab
➢Click on the Environment Variables button
➢ Look under System Variables for "Path"Click on "Path" and then click edit
➢Add the following to the end of the Path:
;C:\Program Files\Java\jdk1.8.0_152\bin
• Click OK.
![Page 34: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/34.jpg)
Setting CLASSPATH - Windows
• Look to see if there is a variable named CLASSPATH
• If there is not, then Click the "New" button.
➢ For the variable name, type:
CLASSPATH
➢ For the value, type: .; (that period semicolon)
➢Click OK. Exit out of all the open windows
![Page 35: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/35.jpg)
Installed Correctly?• Open up a command prompt.
– On Windows:
➢ Open Command Prompt
- On MAC OSX:
➢ Open the Applications folder,
open the Utilities folder, then open the Terminal application.
• Type java and hit enter
➢ "command not found“ means java is not installed correctly
➢ list of options for running java means installed ok
• Type java -version and hit enter
➢ It should list version you installed (e.g. 1.8.0_152)
![Page 36: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/36.jpg)
Write Compile Execute • A human writes Java code, known as source code (.java file)
– Type a HelloWorld program in your editor and save as HelloWorld.java
• The Java compiler converts the source code into machine code or byte code (.class file)
– javac HelloWorld.java
• The computer has a Java Virtual Machine (JVM), which translates the byte code into instructions that the specific computer’s processor can understand.
– java HelloWorld
• A .class file can be used on any computer that has a Virtual Machine, no matter what platform the class file was created on (platform independence)
• Output – messages printed to the screen
![Page 37: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/37.jpg)
Function Unix MS-DOSChange directory cd cd
Directory list ls dir
Copy files cp copy
Move files mv move
Delete files rm del
Make directory mkdir mkdir
Delete directory rmdir rmdir
Handy Commands used on the command line
![Page 38: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/38.jpg)
UNIX Command Help
• See the E115 Textbook
(http://ncsu.orgsync.com/org/e115/)
![Page 39: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/39.jpg)
Traverse Directory Tree
• cd (change directory)
• cd .. (move up to next higher directory)
• cd ../../.. (move up multiple directories)
• cd ~ (move to home dir, unix only)
• cd / (move to root directory)
![Page 40: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/40.jpg)
What’s in a directory?
• ls list contents of directory (unix)
• ls -l list the contents in long format (all information, size, date, owner, etc.) (unix)
• dir list contents of directory (ms-dos)
• ls -a list ALL files, even "." (dot) files and hidden files (unix)
• ls -la lists ALL files in long format (unix)
• dir /a lists ALL files in long format (ms-dos)
![Page 41: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/41.jpg)
Organize your CSC116 Files
• mkdir – make directory
• Try it (start in home directory):– mkdir csc116
– cd csc116
– mkdir exercises
– mkdir projects
– cd exercises
– mkdir Lab1
– cd Lab1
![Page 42: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/42.jpg)
Helpful Tricks/Shortcuts
• Up/Down arrows – Recall previous commands
• Tab completion – Completes commands/file names
• Ctrl + C – to regain command prompt if system is “hung up”
![Page 43: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/43.jpg)
Classic First Program• Write a program that prints the text “Hello, World!” to the
screen
public class HelloWorld {
public static void main(String[ ] args) {
System.out.println(“Hello, World!”);
}
}
RULE:
The name you give your class MUST be the same name you give your file. Thus, the above program must be saved in a file called HelloWorld.java
![Page 44: CSC116: Introduction to Computer Programming•Two midterm exams •One final exam •Check the course schedule on our website for dates. You will have a 2-day exam window. –Schedule](https://reader033.fdocuments.in/reader033/viewer/2022042011/5e72842d379d08511132fced/html5/thumbnails/44.jpg)
During Lecture Assignment• Go to our Moodle page and work on the
HelloWorld.java assignment:/**
* This is an example class that illustrates printing a message to the screen
*
* @author YOUR NAME
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World! My name is [put your name here].");
System.out.println("I [am new to programming, have done some Java/C/etc. programming].");
System.out.println("I live in [city, state (country if not usa)]."); System.out.println("I [work as a Y at company X, am a full-time student, etc.]"); System.out.println("I use a [pc, mac, etc] with the [Windows 7/8/10, OSX, Linux, etc]
operating system.");
}
}