E N D
COSC 1323 Syllabus COSC 1323 Concepts IClass protocol (what is a protocol?)Homework each week. Due before class starts on ThursdaysSyllabus COSC 1123 Concepts I Lab Advanced Computing Lab JBWS 166Labs due each Friday by the end of the day.Turn labs in to me or JBWS 273 box Note: do not turn in to Dr. Baker (she will lose it!) Class Website Schedule faculty.stedwards.edu/johnc Notes are intended as outline of class lectures.
COSC 1323 Fall 2012 Example Flowchart – note 3 symbols used. Start Set area = 0 Set radius = 0 Input / get radius Compute area = π xRxR Output “Area of circle with radius “ + radius + “ is “ + area Stop
ReviewUser-defined variable names (see page 20 for keywords) Data types 6 a hello 2.7 8283 integer character String floating point integer In java 6 ‘a’ “hello” 2.7 8283 int,short,long char String double, float int, short, long Declaring a variable int score = 85; double gpa = 2.8; String fname = “Jill”; String greeting = “What’s up?”;
Primitive Data types int short long byte char boolean float doubleSee our web site for link If memory space costs $5000 per byte, hmm…….. Primitive data type quiz5.6 ‘a’ false -64 -2.12434235 ‘5’ “Jill” ‘\n’ “b” 0 0.0 4*7 5*3.1
Review To obtain user input from the terminal: • import java.util.Scanner; • Scanner console = new Scanner(System.in); • gpa = console.nextDouble ( ); Example: (after having 1 and 2 in your program:double num1 = 0;System.out.println (“Please enter a number: “);num1 = console.nextDouble( ):
Sample Flowchart
Ask me for 2 numbers, compute the sum and product and tell me the answers. Note: it is ok to tell me “Here are the answers: the sum of num1 and num2 and the product of num1 and num2 Or if you can, tell me the actual answers. Here we go ----------- Do you have your tools? Ask me for a couple numbers. I will pick people to play the game.
Sample Flowchart
if – else construct if (newRate > oldRate) { cost = price * newRate;System.out.println(“New cost is “ + cost); } else { cost = price * oldRate;System.out.println(“No change to cost. Cost is “ + cost); } Note the use of the concatenation operator +
Note that an if does not require an else. if ( code > oldCode) { System.out.println(“Code has changed. New code: “ + code); } System.out.println (“Hello Joe”); Now I’ll put some examples on the board to try to trick you
Let’s work on the lab 2 flowchart. Note: Answering questions in the lab: Read the lab at least 5 times. Complete a flowchart for the program that you are working on. (it doesn’t have to be perfect, but it does have to be complete) What is a “camden box” in a flowchart? (think chocolate chip cookies)
VocabularyAlgorithmprotocolGUICLI linux emacs Integer The integers are ‘closed’ under all 5 operations Modulo arithmetic 5%3 Assignment operator Equality operator (only for primitive data types) Add to this list every day
int num1 = 3; System.out.println(“Hello “ + num1 + “ cats”); System.out.print(“well, “);System.out.println(“well.”); System.out.println(“So, let’s go \n” + “party!”); Pop a new line - - how?, automatic?System.out.println(“Mary said \”hello!\” to Sam.”);
T / F char is a primitive data type. Example: char letter = ‘k’; T / F String is a primitive data type. Example: String fname = “Jill”; T / F boolean is a primitive data type. Example: booleanitIsHot= false;
Announcement! On Tuesday we will have a quiz the first 10 minutes of class. a) Bring your prop sheetb) Maybe this will let me know a little about what/how questions are asked.