CSC141 Computer Science I Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA 19383 zjiang@wcupa.edu
Table of Contents Introduction Plain text format printout Variable and its value type Expression & operator Math.pow & Math.sqrt Combined assignment DecimalFormat String
Welcome Why this class? Job hunting Something help you to stand out! WCU graduated, Database, Software Engineering, … vs. UPenn, Temple, Drexel, … Something help you to stand out! — How do you like to be introduced?
Research project Critical thinking, communication, well-plan, etc. Real competition, deadline, pressure More realistic system, complex programming, for instance, http://www.cis.temple.edu/~jiang/RSU_Van.pptx. Student opportunities: http://www.cs.wcupa.edu/~zjiang/student_info.htm Sponsorship NSF, NSA, etc Industry interns
Student Opportunities Collaboration at international level Course project NSF REU Collaboration at inter-disciplinary level Collaborative work at inter-department level
Industry partners Such as Gnostech, Chase, etc. Invited talks in courses Seminars or guest speeches Curriculum review/assessment Permanent intern opportunities
Attract students and keep them continuously working hard Goal Competitive students entrepreneurially and computationally empowered citizenries Temple, NYU, etc. IBM, SAP, Vanguard, Bell lab, etc. Key Attract students and keep them continuously working hard Strategy Real-world computing paradigms and principles in an obstacle-less learning
No pain, no gain Need to handle those things coming from pressure: frustration, upset, madness, etc. Looking for solution, not excuse. Deadline!
Highlights in class materials (available on class website) Textbook Thinking process (instead of resultant program) Hands-on experience Happy ending!
Print-out Code 2-1 (Welcome.java), page 27 Names Main { } and ( ) Println and print (Code 2-3, page 35) \n (Code 2-5, page 36), \t (Code 2-6, page 37), and table 2-2. // (not \\) , page 77 Java is case-sensitive
What a println statement (one statement only) will generate the following output (one statement only)? This program prints a quote from the Gettysburg Address. "Four score and seven years ago, our 'fore fathers' brought forth on this continent a new nation." What a println statement (one statement only) will generate the following output? A "quoted" String is 'much' better if you learn the rules of "escape sequences." Also, "" represents an empty String. Don't forget to use \" instead of " ! '' is not the same as "
Variable Code 2-7 (Variable.java), page 39 Type (declaration) Name, page 43 Begin with [a]-[Z], or _, or $ Contain only [a]-[Z], [0]-[9], _, and $ No keyword Case distinct Samples, table 2-4, page 43
Assignment Assignment Left is a single variable Right is a legal expression Initialization, page 53 Value of variable, page 53 Execution time line, page 55
11/13/2018
Expression Operator (Increment.java) Complete list, Table 2-7, page 55 Precedence order, table 2-8, page 58 Prefix/postfix increment (decrement), page 190-191 n[x][y][pd].counter[type]++ Casting, page 65 17/3=? 17.0/3=? (double)17/3 = ?
Types, Code 2-10, page 46 Sample, Code 2-18, page 59 10% off?
Discrete Types byte short int long Continuous Types float double Non-numeric Types boolean char 11/13/2018
Type Representation Bits Bytes #Values boolean True or False 1 N/A 2 char ‘a’ or ‘7’ or ‘\n’ 16 216 = 65,536 byte …,-2,-1,0,1,2,… 8 28 = 256 short int 4 > 4.29 million long > 18 quintillion float 0.0, 10.5, -100.7 32 double 64 11/13/2018
double float long int boolean short char byte 11/13/2018
Advanced techniques Math.pow and Math.sqrt, page 62 Combined assignment, table 2-13, page 64 Scope, page 75-77
Keyboard Input Code 2-29 (Payroll.java), page 87
String Displaying message, Code 2-32, page 94 Input, converting a string to number, Code 2-33 (PayrollDialog.java), page 97 String to Number Parse, table 2-18, page 96 String value of, table 9-7, page 581 Number to String – Simple! 12+ “ ”
String processing StringDemo.java indexOf, table 9-4, page 572 substring, table 9-5, page 575 Length, Code 2-21, page 73 charAt, toLowerCase, toUpperCase, Code 2-22, page 74 Sting.valueOf, table 9-7, page 581
Example Ex 4 Self-evaluation questions: Merge 2 strings a and b? Split 1 string into 2 parts? Cut the head? Cut the tail? Take the middle? Search?