1 / 48

AP Computer Science

AP Computer Science. Welcome. Computer Science at West. Robotics Programming (RobotC) (One Semester) VEX Robotics/Engineering Computer Science I and II (Pascal) (One semester each) AP Computer Science (Java) (One year) Prepares students for the ‘A’ level exam

velmab
Download Presentation

AP Computer Science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AP Computer Science Welcome

  2. Computer Science at West • Robotics Programming (RobotC) (One Semester) • VEX Robotics/Engineering • Computer Science I and II (Pascal) (One semester each) • AP Computer Science (Java) (One year) • Prepares students for the ‘A’ level exam • Advanced Computer Projects (One semester, can be taken repeatedly) • Developing original software • Robotics Projects • VEX Robotics Challenge (Mainly first semester) • Spring tech conference (Second Semester)/FTC/VEX If we make the finals. • Introduction to Engineering Design • Design process • 2 D and 3D design by hand • 3D design on computer (Inventor)

  3. Today’s Schedule • Introductions • Student Expectations • Lab Rules • Course Overview • Questions • Log in /Set up Shortcuts • Give first challenge

  4. Introductions • You will introduce the people next to you • Name • Previous Programming Experience • Two ideas for potential careers

  5. Student Expectations • Behavior/Discipline Plan: • Students are expected to be safe, responsible and respectful. • Students not following these expectations may expect: verbal warnings, removal from class pending conference, parent contact, or referral to administration.

  6. To be successful in this course: • Stay focused and productive in the classroom • Excellent attendance • Let your projects, daily work, quizzes and tests display your best effort • Feel free to talk with me about your projects, questions, etc.

  7. Computer Lab Rules • No gum in class • No food or drink in the lab (except water with a lid at approved locations) • No headphones or music except on days selected by teacher • Absolutely no off-task Internet usage (e-mail, games, chat, etc – anything other than class related) • Absolutely no off-task Computer usage (ask teacher permission to use equipment for anything other than class assignments) • Do NOT download any software (games, utilities, music, etc.) • Do NOT use any “chat” software • No CELL PHONE use in class without permission of Mr. Smith.

  8. Materials Needed • Each student will need a Composition Book or a tabbed off section in your three-ring binder for notes and handouts. • Bring a pen or pencil with you everyday

  9. Class Overview: First Semester • Basic I/O • Math in Java • Decision construct • For loop • Java Docs and Strings • While • Do..while* • Random • Arrays of Primitives • Midterm • More Arrays • Sorting • Intro to Objects • Inheritance • Intro to Gridworld • More OOP • ArrayList Class • Intro to OSI Networking model • Review and Final

  10. Grading Policy • Grading Scale • A .. 90%+ • B .. 80 – <90% • C .. 70 – <80% • D .. 60 – <70% • F .. Below 60% • Assignments • Programs 10 points • Quizzes: 25 points • Tests: 100 Points • Projects: 20 to 100 points • Final: 200 points or 20% of your grade, whichever is less.

  11. Time to Log-on • User Name: Use the ‘ID Number ‘ from your schedule for your user name. • Password: Use your student ID number, also on your schedule to the left of your name, with a ‘.’ after it for your password. You will be asked to change your password on the first time you log in.

  12. Log in and Create Class Folder • Log onto the network • Your log in number is on your student ID number • Your password is your First Initial Last Initial Birthdate. • Example • Susie Kalahan 1/1/2002 • sk112002 • Jose Mahindra 10/15/2001 • jm10152001 • Open YourName Folder • In to top left of the desktop • Make a new folder called APJava • Keep your APJava Folder open

  13. Creating Shortcuts 2) Double Click on ‘APJava’ Folder 1) Double Click on SMITH_GREG-Shortcut

  14. Drag and Drop into your ComputerScience1 Folder. Drag and Drop Into Your APJava Folder Drop

  15. Shortcut to Class Website • www.smithcsrobot.weebly.com Click on ‘AP Computer Science’

  16. Put Shortcut in your Folder Drag and Drop

  17. Syllabus • At home print out the syllabus, have your parents sign it and turn it in.

  18. Getting Started in BlueJ Start with a capital letter. • Open BlueJ • Make a New Project (Folder) • Create a new class (file) Welcome1

  19. Fill in the Class Enter your name, brief description of the program, the date and version 1.0. Delete info between the {} after the public class Welcome1

  20. First Program Enter the following program in BlueJ.

  21. Compiling the Program Click Compile Check for errors.

  22. Running the Program Right click on the class. Select void main() Click OK

  23. Output Screen

  24. Turn in the .java file Rename the java file to YourNameWelcome1 and turn in to the turn in folder. Include your name in the file name

  25. public class Welcome1 Breaking down the code. • Begins the class definition of class Welcome1 • Every program must include the definition of at least one class. • Class names begin with a capital letter • The class name must match the file name (Welcome1.java) • This is case sensitive • The file must have a .java extension (BlueJ should do this for you.) • Identifier rules • //Series of characters (letters, numbers, digit, _, $ • //Must not start with a number • //Cannot be a reserved word (purple in editor) • Must describe what it is storing! • Java IS Case sensitive Get out your notes.

  26. { • Same as BEGIN in Pascal • Marks the beginning of the main body of the class. • Needs to match up with a } • Indent between the {}

  27. public static void main(String args[]) • This is the starting point of every java application • (Main body of the program) • () after main indicate it is a method (Like a procedure) • Java classes usually contain more than one method • Exactly one of these methods must be called main and defined as above for the program to run. • Methods perform tasks and return information. Kind of like functions • void indicates that it will return nothing. • String args[] is required for the main's definition. More details later.

  28. System.out.println("Welcome to Java programming!"); • System.out is the standard output object for showing info in the command window • The stuff inside () are the arguments • System.out.println(); Displays the arguments and returns to the next line • Like writeln() in Pascal • "Wel..." This is a String of characters, message or string literal.

  29. Comments and Common Errors • When successfully compiled it creates a Class file for Welcome1 called Welcome1.class • This file contains the byte codes that represent this application • Some common errors • "bad command or file name", "javac: command not found", ""'javac' is not recognized as an internal or external command, operable program or batch file" • Try: The system's path environment was not set properly. Check java.sun.com/j2se/5.0/install.html • “Public class ClassName must be defined in file called ClassName.java" • Try: Checking that the file name exactly matches the class name.

  30. Review // Mr. Smith // First Program // Today’s date public class Welcome1 { //main method begins execution of Java application public static void main(String [] args) { //The start of the method System.out.println("Welcome to Java programming!"); }//End of method main } //End of class Welcome1 Describe the following

  31. More on System.out public class Welcome1 { //main method begins execution of Java application public static void main(String [] args) { //The start of the method System.out.print("Welcome to "); //Stays on the same line System.out.println(“Java programming”); }//End of method main } //End of class Welcome1

  32. Showing Multiple lines public class Welcome1 { //main method begins execution of Java application public static void main(String [] args) { //The start of the method System.out.println(“Welcome \nto \nJava \nprogramming”); }//End of method main } //End of class Welcome1

  33. Escape Sequences \ is an ‘escape’ character Some Common Escape Sequences \n for new line \t horizontal tab \r Carriage return, but on the same line \\ used to print the \character \” Used to display “

  34. Displaying Formatted Text (printf) public class Welcome1 { public static void main(String [] args) { //The start of the method System.out.printf(“%s\n%s\n”,"Welcome “,” to Java programming!"); }//End of method main } //End of class Welcome1 System.out.printf(Format String, Comma separated data to display) Format String Can contain fixed text, escape sequences and format specifiers Format Specifiers: Begin with % %s is a place for a string.

  35. System.out.printf( “format-string” [, arg1, arg2, … ] ); • Format String: • Composed of literals (String characters) and format specifiers (%d, %-,.2f) • Arguments are required only if there are format specifiers in the format string. Format specifiers include: flags, width, precision, and conversion characters in the following sequence: • % [flags] [width] [.precision] conversion-character ( square brackets denote optional parameters )

  36. Flags • % [flags] [width] [.precision] conversion-character ( square brackets denote optional parameters ) • Flags: - : left-justify ( default is to right-justify ) + : output a plus ( + ) or minus ( - ) sign for a numerical value 0 : forces numerical values to be zero-padded ( default is blank padding ) , : comma grouping separator (for numbers >= 1000) : space will display a minus sign if the number is negative or a space if it is positive

  37. Width • % [flags] [width] [.precision] conversion-character ( square brackets denote optional parameters ) • Specifies the field width for outputting the argument and represents the minimum number of characters to be written to the output. • Include space for expected commas and a decimal point in the determination of the width for numerical values.

  38. Precision • % [flags] [width] [.precision] conversion-character ( square brackets denote optional parameters ) • Used to restrict the output depending on the conversion. • It specifies the number of digits of precision when outputting floating-point values . Numbers are rounded to the specified precision.

  39. Common Conversion Characters • % [flags] [width] [.precision] conversion-character ( square brackets denote optional parameters ) • d : decimal integer [byte, short, int, long] • f : floating-point number [float, double] • c : character Capital C will uppercase the letter • s : String Capital S will uppercase all the letters in the string • n : newline Platform specific newline character- use %n instead of \n for greater compatibility

  40. Examples • % [flags] [width] [.precision] conversion-character ( square brackets denote optional parameters ) • System.out.printf("Total is: $%,.2f%n", dblTotal); • , ->Comma Separated • .2 ->Two digits to the right of the decimal • f -> Floating point notation (real value) • n -> Returns to the next line • dblTotal -> The variable whose value will be displayed • System.out.printf("Total: %-10.2f: ", dblTotal); • - -> Left justified • 10 -> 10 Spaces for displaying the value • .2 -> Two digits to the right of the decimal • f -> Floating point notation (real value) • System.out.printf("% 4d", intValue); • Space -> Will leave space if positive or a – if negative • 4 -> Four spaces for displaying the value • d -> Showing an integer value.

  41. More Examples:Controlling integer width with printf The%3dspecifier means a minimum width of three spaces, which, by default, will be right-justified

  42. Left-justifying printf integer output To left-justify integer output with printf, just add a minus sign (-) after the%symbol, like this:

  43. The printf zero-fill option To zero-fill your printf integer output, just add a zero (0) after the%symbol, like this:

  44. printf integer formatting As a summary of printf integer formatting, here’s a little collection of integer formatting examples. Several different options are shown, including a minimum width specification, left-justified, zero-filled, and also a plus sign for positive numbers.

  45. printf - floating point numbers

  46. printf string formatting

  47. Quick Review • Starting a project in BlueJ • Open BlueJ • Select your workspace (Folder) • Project->New Project • Click on ‘Class’ to create a class • Double click on icon to edit the code • Parts of your program • publicclass FormattedPrint • { • publicstaticvoid main(String [] args) • {//The start of the method • System.out.printf("%s\n%s\n","Welcome "," to Java programming!"); • }//End of method main • } • Time to get started.

  48. Your first programs • Poem/Song: (YourNamePoem-Song) • Create or modify a poem or song to display from your Java Program. • You will need to incorporate at least one printf. • Check: Using printf (YourNameCheck) • No input • Display information on the screen for a check with your generous donation to the West Salem Robotics Club. • You will need to incorporate at least one printf.

More Related