Unit 1 Workbook ICS3U
|
|
- Tyler Elijah Caldwell
- 6 years ago
- Views:
Transcription
1 Unit 1 Workbook ICS3U Huntsville High School Computer Science Ian McTavish Name:
2 Table of Contents Unit Expectations for Evaluation... 3 Assessment Due Dates... 3 February 3, Typing Challenge... 3 February 6 - Your First Program... 4 Programming Primer... 7 Most Popular Programming Languages... 7 Must Include... 7 Format... 7 Due Date... 7 Programming Primer Rubric... 8 Feb 7 Output... 9 Output in a Windows Form Methods vs. Properties Feb 8 Variables, Strings Variables Naming Conventions Strings Complete the following table Feb 9 Input U1D5usingVariablesxxx Labels TextBoxes Button RichTextBox Form Code Tip Feb 10 Data Types Feb 13 Careers Summative Intro Feb 14 Math Operations, Concatenation I McTavish ICS3U Workbook January 30, 2012 Unit 1 1
3 Feb Career Summative Work Periods Feb 21 Programming Challenge Summative Feb 22 Wrap up Unit Works Cited Unit 1 I McTavish ICS3U Workbook January 30, 2012
4 Unit 1 Expectations for Evaluation A1. demonstrate the ability to use different data types, including one-dimensional arrays, in computer programs A4. use proper code maintenance techniques and conventions when creating computer programs C2. use appropriate file maintenance practices to organize and safeguard data D3. describe postsecondary education and career prospects related to computer studies Assessment Due Dates Feb 17 Programming Primer Feb 22 Careers Programming Assignment February 3, 2012 What we re covering today: Welcome course overview Assessment & Evaluation Expectations Computer as a tool, not a toy This is your job, welcome to the work world show up, be prepared, focus, work hard Breaks Room keep it clean Where you can go What to do when you re done an assignment Throughout unit 1 you will be working through this workbook, your programming primer, handouts distributed in class and information from our class website. Please contact Mr. McTavish if you unclear as to what you are to do. Typing Challenge The ability to type quickly with no spelling errors will benefit you in this course. Start off each day with All the Right Type. (Student Applications/Business/All the Right Type). Click the course and your name. Explore the different areas and practice! Goal 1: Errors: 0 Goal 2: Errors: 0 WAM: 20 Goad 3: Errors: 0 WAM: 60 One error resulted in 153 errors in a program! I McTavish ICS3U Workbook January 30, 2012 Unit 1 3
5 February 6 - Your First Program When you start the Visual Studio IDE for the first time, you need to quickly orient yourself around the program. Menu Standard toolbar Start Page Note you can create and open projects here. On the Start Page, click Create Project (on the menu File New Project) Select Windows Forms Application (always ask what type of program it is) Give this program the name u1d2windowsxxx (u1 unit 1, d2 day 2, windows the name of the assignment, xxx replace with your initials. Use this format for all program names note: NO SPACES) 4 February 6 - Your First Program I McTavish ICS3U Workbook January 30, 2012
6 The Solution Explorer is where you can see all the files for your program. Form1.cs is the windows form and should be the only file you use at this point. 2. Form Designer This is what your form actually looks like. Nothing much yet This area is also where you view code. On the menu you can switch between code and Designer views. 3. Use the Toolbox to add different windows elements (i.e. buttons, menu bars). Simply drag the item onto your form. We ll use the Button for this program. 4. Whenever an element is selected (Form1 in this diagram), the Properties window shows all the properties that you can set. The buttons allow you to sort them, or access the Events (i.e. a button click) available. 5. The Start Debugging button on the toolbar allows you to build and run your program. The command is also found under the Debug menu. Run it now you should have a form show up, not much, but it s your first program. I McTavish ICS3U Workbook January 30, 2012 February 6 - Your First Program 5
7 From the toolbox, drag the Button onto your form. Make sure your button is selected and in the Properties window (Ctrl W, P), change the (Name) value from button1 to btnshowmessage It s important to name the objects you use with names that are easy to understand: btn this is a button, ShowMessage this tells you what the button does, note there are NO SPACES! Change the Text value to: Show Message You may need to resize the button to show all the words. On the Form Designer, double-click the button, this will take you to the code and add an event for when the button is clicked. This is the following code (note the first two lines are all on one line). private void btnshowmessage_click(object sender, EventArgs e) { } Hit enter and type the following MessageBox.Show("Hello World"); Click the Start Debugging Button, your program should run (if it doesn t, check for spelling mistakes, also MessageBox.Show( Hello World ); should be between the {}. When you click the button on your program, you should get a Hello World Message. A Hello World program is a traditional method of writing your first program. Can you find out who created the first Hello World program? MessageBox is a class that comes with Microsoft s.net programming languages. The Show method allows you to show the message box, Hello World is the String that you are providing as a parameter to display on the message box. 6 February 6 - Your First Program I McTavish ICS3U Workbook January 30, 2012
8 Programming Primer A fundamental goal in this course is learning how to learn. Technology changes at an incredible rate. The programming languages I used in high school simply aren t used anymore we have to assume that you will encounter the same issue. The challenge is to learn the skills and be able to independently learn new programming languages. Your task is to research a programming language and create a Programming Primer that explains how to program in that language. Must Include Brief overview of the language (one paragraph max) How to create a program How to create Output How to declare and initialize variables o Boolean o Integer o Floating Point (Double, or decimal) o String How to get input Basic math operations Concatenating Strings Works Cited with at least two or three citations in MLA style Format You may use any of the following methods to hand in your Programming Primer. Most Popular Programming Languages Java C C# C++ Objective-C PHP (Visual) Basic Python Perl JavaScript Delphi/Object Pascal Ruby Lisp Pascal Transact-SQL PL/SQL Ada Logo R Lua (TIOBE SOFTWARE) Paper (The References tab is useful for adding citations) Website (Google Sites is a free, easy way to create a website Use Cite Your Sources from the school website to add citations) Other check with McTavish Due Date February 17 I McTavish ICS3U Workbook January 30, 2012 February 6 - Your First Program 7
9 Programming Primer Rubric Level 4 (5 marks) Level 3 (6 marks) Level 2 (7 marks) Level 1 (8-10 marks) Marks K 5 items included 6 items included 7 items included All items included K T C A Explanations and samples demonstrate limited understanding Examples and/or samples are not clear There are errors in spelling and/or syntax Examples were ones covered in class Comments Explanations and samples demonstrate some understanding Examples and samples showed some choice of information covered in class There are some errors in spelling and/or syntax Example are slightly different than ones covered in class Explanations and samples demonstrate considerable understanding Examples and samples were obviously selected from class notes and the class textbook There are few errors in spelling and/or syntax Examples are based on class examples and show ability to use in new situations Explanations and samples demonstrate thorough understanding Original examples and samples clearly explain the topic. Citations demonstrate when information was obtained from class notes, the textbook and independent research. There are no errors in spelling and syntax Examples are original and additional examples are created Total: 8 February 6 - Your First Program I McTavish ICS3U Workbook January 30, 2012
10 Feb 7 Output Output is the process where computers make information available outside the computer this could be on a screen, printed or to control a device (a robot s movements would be considered output). You can also output information to a network like the Internet (Deitel, Deitel and Quirk). 1. Create Project Select Console Application 2. Name: u1d3coutputxxx (replace xxx with your initials) 3. Click Ignore when you get the warning the location can t be trusted 4. Add two lines so that the complete program looks like the following using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace u1d3coutputibm { class Program { static void Main(string[] args) { Console.WriteLine("Hello World"); Console.ReadLine(); } } } 5. Debug your program - what happens? 6. We will take some time to understand what is happening. using System; using System.Collections.Generic; using System.Linq; using System.Text; The first four lines are using directives (Microsoft) these allow you to state what namespaces the program will use. For example System is a namespace in the.net Framework. It contains a class called Console which we access in this program (Microsoft). If we didn t have these lines then later in the program we would need to write: System.Console.WriteLine("Hello World");
11 namespace u1d3coutputibm { } Every program should be in a namespace. The braces ({ }) define the block where we put our code (Microsoft Corporation 8). The namespace is automatically the name of the file you should not mess with this! Warning: the most common problem you will encounter is accidently deleting a brace or typing outside of the block! class Program { } C# is an Object Oriented Programming language (OOP) a class is used to create an object. Again, you should not mess with this! static void Main(string[] args) { } This declares a method called Main. For a program to run it requires a Main method. A method is a block of code that performs actions or computations. In Unit 2 we will learn what the rest of the terms represent. Console.WriteLine("Hello World"); Console.ReadLine(); As mentioned before Console is a class in the System namespace. WriteLine is a method thatperforms an action (in this case writes a line of text to the console screen). The ReadLine method waits for the user to type - we only need this so that the program doesn t finish! 10 Feb 7 Output I McTavish ICS3U Workbook January 30, 2012
12 Output in a Windows Form Open u1d2windowsxxx (from yesterday). Add the following line after your MessageBox line: this.text = "Hello World"; Run the program what do you notice changes after you ve pressed the button and clicked OK on the MessageBox? What happens if you change the line to the following: btnshowmessage.text = "Hello World";.Text is a property that you can set and get. Add a Textbox, change the (Name) property to txtoutput. Change the code so that when the button is pressed you change the Text property to some text. Methods vs. Properties A method is like an action for a car there would be a drive action. A property is a value. A car has a colour property. Feb 8 Variables, Strings Computer memory stores arbitrary bit patterns. As with a string of letters, the meaning of a string of bits depends on how it is used. The particular scheme that is being used for a particular string of bits is a data type. A data type is a scheme for using bits (binary digits) to represent values. These values are not just numbers, but any kind of data that a computer can process. All values in a computer are represented using one type of data or another. In any programming language, there are many different data types and even ones you, as a programmer, can create. Some types of data are so fundamental to programmers that most programming languages have built in ways to represent them. These are the primitive data types. The names of the eight primitive data types are: I McTavish ICS3U Workbook January 30, 2012 Feb 8 Variables, Strings 11
13 Int double long short byte float boolean char These data types are referred to as primitive because they are the foundations upon which larger parts of a program are built. The first six listed above are used to store numeric data; boolean and char are generally used to store alphabetic or character information. The basic difference between the numeric primitives is in the range of numbers they can store. Many real-world programs deal with massive amounts of data (billions of data items) and, thus, the smaller size types (byte and short) may save significant amounts of space and time. But we will not use that much data in this course. Usually you should use integers (for data that will not contain decimal places) or double (data containing decimal places) for your numeric data. Variables Essentially, a variable is a name for a location in computer memory which uses a particular data type to hold a value. The integer value appears in a storage space. The storage space is titled "mynumber" and is an int (or integer) type. Note the naming convention for variables: a name for a variable (as well as for a method) usually starts with a lower case letter. A word that is part of the name starts with an uppercase letter (like "Number"), unless it is at the start of the name. These conventions are not required by syntax, but are useful to follow since they makes programs more readable. Naming Conventions Use a variable name that effectively describes the value being stored within it. Use only the characters 'a' through 'z', 'A' through 'Z', '0' through '9', character '_'. Start with lower case letter. First letter of other words in name are capitalized; eg. hellothere A variable name cannot contain the space character. Do not start with a digit. The length of a variable name is <256 characters. Upper and lower case count as different characters; eg. SUM and Sum are different names. A name cannot be a reserved word. A name must not already be in use in this part of the program. 12 Feb 8 Variables, Strings I McTavish ICS3U Workbook January 30, 2012
14 Strings Strings are a special type of variable. An integer will always take up the same amount of memory regardless of its value. A string could be as small as a letter and as big as the works of Shakespeare. Many times there are numbers that should be stored as strings. A telephone is a good example since you won t add telephone numbers together or do other math operations a string is the most appropriate way to store it. Yes/no True/false Boolean Counting number Integer Decimal Number Double Word String The following code example shows how to declare, initialize and output a String variable. Notice the lines that start with // - these are comments that won t run but explain the code. //Declare a string variable String strvar; //Initialize a string variable strvar = "Hello World"; //Output the string variable MessageBox.Show(strVar); I McTavish ICS3U Workbook January 30, 2012 Feb 8 Variables, Strings 13
15 Complete the following table Data Type Console (Unmanaged) Windows Form (Managed) Character Range: Declare Initialize String Range: Integer Range: to (no decimal places) Declare Initialize Declare int x; Initialize x = 12; Declare System.String varstring1; Initialize varstring1 = "This is a string."; Declare Int32 x; Initialize x = 12; Double Range: Declare Initialize Declare Initialize Boolean Range: Declare Initialize Declare Initialize Valueless Range: Declare Initialize Declare Initialize 14 Feb 8 Variables, Strings I McTavish ICS3U Workbook January 30, 2012
16 Feb 9 Input Please read: answer the following questions. is the data flowing into the system from outside. An example is: Comment [I1]: Input is the action of manipulating the input into a more useful form. An example is: Comment [I2]: Processing is the information flowing out of the system. An example is: Comment [I3]: Processing I McTavish ICS3U Workbook January 30, 2012 Feb 9 Input 15
17 U1D5usingVariablesxxx The goal is to create a windows program that uses a variety of variables. The Form will require the user to input their name (string), the number of items they are purchasing (integer) and the price of the item (double). The response will look as follows: Bob, You ordered 3 items at a price of $1.99 each. Your total cost is: $ Create a new Windows Form Application 2. Make sure to save it in the following location: D:/unit 1 3. Name: u1d5usingvariablesxxx (where xxx is your name) 4. On the form add the following items: 3 labels, 3 TextBoxes, 1 Button, 1 RichTextBox 5. Change the following properties Labels Properties Label1 Label2 Label3 Text Name Quantity Price TextBoxes Properties TextBox1 TextBox2 TextBox3 Name txtname txtquantity txtprice Anchor Top, Left, Right Top, Left, Right Top, Left, Right Button Properties Text Name Button Calculate btncalculate RichTextBox Properties RichTextBox Name rtboutput Anchor Top, Left, Right Form Properties RichTextBox Text Using Variables WindowState Maximized The Anchor property will resize the item so that it stays the same distance from the side you choose. It s an easy way to allow your form to look good regardless of the size. 16 Feb 9 Input I McTavish ICS3U Workbook January 30, 2012
18 1. Run the program to ensure there are no errors. Close the program after it opens. 2. Double-click the button to create the button click method. 3. Here is the pseudocode for the program you are creating Declare variable name string Declare variable quantity integer Declare variable price double Declare variable total double Declare variable output string Initialize name to txtname->text Pseudocode is where you plan the code you are writing. You write it as code but don t worry about the syntax. Then when you re ready to write the program you fix the syntax so it is actually code. Initialize quantity to txtquantity->text (make sure to convert to double) Inititialize price to txtprice->text (make sure to convert to integer) Initialize total to price*quantity (* is used to multiply) Initialize output to a concatenated string name, \n\nyou ordered, quantity, items at a price of $1.99 each. Your total cost is: $5.97. Concatenation is where you combine two strings. Using the information covered in class, declare the variables. The last part is tricky so feel free to ask for the code example. Code Tip //Declare variable Double dblprice; //Initialize - Try Parse takes the text and converts it to a Double Double.TryParse(txtPrice.Text, out dblprice); //Output - Concatenates "The Price is: " with the price in a dollar format MessageBox.Show(String.Concat("The Price is: ",dblprice.tostring("$0.00"))); I McTavish ICS3U Workbook January 30, 2012 Feb 9 Input 17
19 Feb 10 Data Types Throughout this course you will use the following types of variables on a regular basis: integers, floating points, strings, and Boolean values In this walkthrough you will create a program for a ball manufacturer that will take the radius of a ball, the quantity of balls to make and output You will need 10m 2 of material (10m 2 would be replaced with the calculated surface area of the ball). It was determined that the following variables are needed. Variable Variable Name Type of Variable Radius of the ball dblradius Double Quantity of balls intquantity Integer Surface Area of the ball dblsurfacearea Double Output stroutput String PI (used to calculate radius dblpi const Double Whether radius is a valid value blradiusinput Boolean Whether quantity is a valid value blquantityinput Boolean You ll notice that Pi is const Double. Const is a constant since Pi never changes using const prevents you from being able to change the value of Pi in the program. Calculate surface area of all the balls Output results We will also need the following items on our form: Item Name Property TextBox txtradius TextBox txtquantity Button btncalculate RichTextBox rtboutput The labels weren t included since we won t use them in the program. Pseudocode Declare variables Initialize variables Calculate Surface Area 18 Feb 10 Data Types I McTavish ICS3U Workbook January 30, 2012
20 Complete Code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace u1feb10datatypesibm { public partial class Form1 : Form { //Declare constants const Double dblpi = 3.14; public Form1() { InitializeComponent(); } /* * btncalculate_click method * Runs when the buton is pressed */ private void btncalculate_click(object sender, EventArgs e) { //Declare variables Double dblradius; Int32 intquantity; Double dblsurfacearea; String stroutput; Boolean blradiusinput; Boolean blquantityinput; //Initialize variables blradiusinput = Double.TryParse(txtBallRadius.Text, out dblradius); blquantityinput = Int32.TryParse(txtQuantity.Text, out intquantity); //Calculate Surface Area dblsurfacearea = 4 * dblpi * dblradius *dblradius; //Calculate surface area of all the balls dblsurfacearea = dblsurfacearea * (Double)intQuantity; //output results stroutput = dblsurfacearea.tostring(); rtboutput.text = "You will need " + stroutput + "m^2 of material."; rtboutput.text += "\nvalid Radius: " + blradiusinput.tostring(); rtboutput.text += "\nvalid Quantity: " + blquantityinput.tostring(); } } } I McTavish ICS3U Workbook January 30, 2012 Feb 10 Data Types 19
21 Feb 13 Careers Summative Intro This assignment will be handed out in class. Feb 14 Math Operations, Concatenation Stage 1: Integer Math Purpose: To create a program that performs basic math calculations. 1. txtop1 2. txtop2 3. txtanswer 4. btnadd 5. btnsubtract 6. btnmultiply 7. btndivide 8. btnmod 9. lblequal = * / % 8 Diagram 1 1. Set up the form to look like the diagram above. This requires: 3 TextBoxes 5 Buttons 1 Label 2. Change the properties of each of the items. Change the name values to the ones indicated in the diagram 1. Change the Text values to the values in the text boxes. Also, change the Name property of the Form to Calculate by Bob. (Replace Bob with your name). 3. Double click btnmod, On the next page is the code I used. 20 Feb 13 Careers Summative Intro I McTavish ICS3U Workbook January 30, 2012
22 1. /* 2. This function runs when the Modulus button is pressed. 3. It divides Operator 1 by Operator 2 and returns the 4. remainder. 5. */ 6. private: System.Void btnmod_click(system.object sender, System.EventArgs e) { 7. //Declare Variables 8. System.Int32 iop1; 9. Int32 iop2; 10. Int32 ianswer; //Get values 13. Int32.TryParse(txtOp1.Text,out iop1); 14. Int32.TryParse(txtOp2.Text, out iop2); 15. //Calculate Answer 16. ianswer = iop1 % iop2; //Display result 19. txtanswer.text = ianswer.tostring(); 20. } Note: The numbering will not be the same as yours, it is used so that you know that line 6 is only on one line. Also, be careful where you type not the placement of brackets! 4. Run the program, if there are errors, use View Other Windows Error List to identify the errors. Try to fix them yourself before asking for help. 5. Add code for each of the other buttons (Save yourself some typing, use copy and paste and then just modify the relevant line). 6. Run the program, make sure it works properly. Stage Two: Double Math Purpose: To modify your program so you can also perform calculations using decimal numbers. 1. In Form Designer, click and drag to select all the items, Copy the items (either right-click, Ctrl-C or use the menu). 2. Past the items below. 3. You will need to set the Name property. Use the same format as above, but add D to the end of each name. Example: txtop1d, btnaddd The D represents Double. 4. Use the code from above, but remember to use Double instead of Int32 (you ll also need to modify the TryParse statement. Again, make sure to add D to the end of variable names. 5. See Mr. McT for sample code. Note: You can t do Modulus with Double values! Bonus, can you use an If statement to prevent divide by 0? I McTavish ICS3U Workbook January 30, 2012 Feb 14 Math Operations, Concatenation 21
23 Feb Career Summative Work Periods Remember to refer to the rubric to ensure you get maximum marks. Feb 21 Programming Challenge Summative Put your skills to the test! Feb 22 Wrap up Unit 1 There will be an online practice test so you can prepare for the final exam. 22 Feb Career Summative Work Periods I McTavish ICS3U Workbook January 30, 2012
24 Works Cited Deitel, P. J., H. M. Deitel and D. T. Quirk. Visual C How to Program. 2nd. Upper Saddle River: Pearson Education, Microsoft Corporation. "C# Language Specification Version 4.0." C# Language Specification Version 4.0. Microsoft Corporation, Microsoft. Namespaces (C# Programming Guide) February 2012 < using (C# Reference) February 2012 < US/library/zhdeatwt(v=vs.80).aspx>. TIOBE SOFTWARE. TIOBE Programming Community Index for January February 2012 < Index Anchor boolean Boolean button click byte char class... 6 concatenation constant data type Debugging... 5 double Double float floating points Form Designer... 5 IDE... 4 Int integers long MessageBox... 6 method... 6, 10 Modulus namespace Object Oriented Programming OOP parameter... 6 primitive Properties... 5 pseudocode Pseudocode RichTextBox short Solution Explorer... 5 strings Strings Toolbox... 5 TryParse Visual Studio IDE... 4 Windows Forms Application... 4 I McTavish ICS3U Workbook January 30, 2012 Works Cited 23
IT 374 C# and Applications/ IT695 C# Data Structures
IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationCALCULATOR APPLICATION
CALCULATOR APPLICATION Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
More informationYour First Windows Form
Your First Windows Form From now on, we re going to be creating Windows Forms Applications, rather than Console Applications. Windows Forms Applications make use of something called a Form. The Form is
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Overview. C# program structure. Variables and Constant. Conditional statement (if, if/else, nested if
More informationMidterms Save the Dates!
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Primitive Data Types Arithmetic Operators Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch 4.1-4.2.
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More information2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program
More informationFirst start a new Windows Form Application from C# and name it Interest Calculator. We need 3 text boxes. 4 labels. 1 button
Create an Interest Calculator with C# In This tutorial we will create an interest calculator in Visual Studio using C# programming Language. Programming is all about maths now we don t need to know every
More informationYou can call the project anything you like I will be calling this one project slide show.
C# Tutorial Load all images from a folder Slide Show In this tutorial we will see how to create a C# slide show where you load everything from a single folder and view them through a timer. This exercise
More informationEx: If you use a program to record sales, you will want to remember data:
Data Variables Programs need to remember values. Ex: If you use a program to record sales, you will want to remember data: A loaf of bread was sold to Sione Latu on 14/02/19 for T$1.00. Customer Name:
More informationCOMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016
COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016 Learn about cutting-edge research over lunch with cool profs January 18-22, 2015 11:30
More informationLast Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Writing a Simple Java Program Intro to Variables Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch
More informationObject-Oriented Programming
Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,
More informationCS 231 Data Structures and Algorithms, Fall 2016
CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard
More informationLecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University
Lecture 2 COMP1406/1006 (the Java course) Fall 2013 M. Jason Hinek Carleton University today s agenda a quick look back (last Thursday) assignment 0 is posted and is due this Friday at 2pm Java compiling
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationVARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals
VARIABLES WHAT IS A VARIABLE? A variable is a storage location in the computer s memory, used for holding information while the program is running. The information that is stored in a variable may change,
More informationAP Computer Science Summer Work Mrs. Kaelin
AP Computer Science Summer Work 2018-2019 Mrs. Kaelin jkaelin@pasco.k12.fl.us Welcome future 2018 2019 AP Computer Science Students! I am so excited that you have decided to embark on this journey with
More informationDeveloping for Mobile Devices Lab (Part 1 of 2)
Developing for Mobile Devices Lab (Part 1 of 2) Overview Through these two lab sessions you will learn how to create mobile applications for Windows Mobile phones and PDAs. As developing for Windows Mobile
More informationCreating a C++ Program
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an
More informationTutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic
Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic Outline 6.1 Test-Driving the Enhanced Inventory Application 6.2 Variables 6.3 Handling the TextChanged
More informationLESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT
LESSON VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT PROF. JOHN P. BAUGH PROFJPBAUGH@GMAIL.COM PROFJPBAUGH.COM CONTENTS INTRODUCTION... Assumptions.... Variables and Data Types..... Numeric Data Types:
More informationREVIEW. The C++ Programming Language. CS 151 Review #2
REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,
More informationLesson 1. Introduction to Programming OBJECTIVES
Introduction to Programming If you re new to programming, you might be intimidated by code and flowcharts. You might even wonder how you ll ever understand them. This lesson offers some basic ideas and
More informationIntroduction to Java Unit 1. Using BlueJ to Write Programs
Introduction to Java Unit 1. Using BlueJ to Write Programs 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More information5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.
Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you
More informationTOPIC 2 INTRODUCTION TO JAVA AND DR JAVA
1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared
More information1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8
Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(
More informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationJava Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1
COMP 210: Object-Oriented Programming Lecture Notes 1 Java Program Structure and Eclipse Robert Utterback In these notes we talk about the basic structure of Java-based OOP programs and how to setup and
More informationIntroduction to the C++ Programming Language
LESSON SET 2 Introduction to the C++ Programming Language OBJECTIVES FOR STUDENT Lesson 2A: 1. To learn the basic components of a C++ program 2. To gain a basic knowledge of how memory is used in programming
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationForm Properties Window
C# Tutorial Create a Save The Eggs Item Drop Game in Visual Studio Start Visual Studio, Start a new project. Under the C# language, choose Windows Form Application. Name the project savetheeggs and click
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Chapter 2: Data and Expressions CS 121 1 / 51 Chapter 1 Terminology Review
More informationFull file at
Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional
More informationPrimitive Data, Variables, and Expressions; Simple Conditional Execution
Unit 2, Part 1 Primitive Data, Variables, and Expressions; Simple Conditional Execution Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Overview of the Programming Process Analysis/Specification
More information************ THIS PROGRAM IS NOT ELIGIBLE FOR LATE SUBMISSION. ALL SUBMISSIONS MUST BE RECEIVED BY THE DUE DATE/TIME INDICATED ABOVE HERE
Program 10: 40 points: Due Tuesday, May 12, 2015 : 11:59 p.m. ************ THIS PROGRAM IS NOT ELIGIBLE FOR LATE SUBMISSION. ALL SUBMISSIONS MUST BE RECEIVED BY THE DUE DATE/TIME INDICATED ABOVE HERE *************
More informationC++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5
C++ Data Types Contents 1 Simple C++ Data Types 2 2 Quick Note About Representations 3 3 Numeric Types 4 3.1 Integers (whole numbers)............................................ 4 3.2 Decimal Numbers.................................................
More informationAP Computer Science A
AP Computer Science A 1st Quarter Notes Table of Contents - section links Click on the date or topic below to jump to that section Date : 9/8/2017 Aim : Java Basics Objects and Classes Data types: Primitive
More informationIBSDK Quick Start Tutorial for C# 2010
IB-SDK-00003 Ver. 3.0.0 2012-04-04 IBSDK Quick Start Tutorial for C# 2010 Copyright @2012, lntegrated Biometrics LLC. All Rights Reserved 1 QuickStart Project C# 2010 Example Follow these steps to setup
More informationIntroduction to C# Applications Pearson Education, Inc. All rights reserved.
1 3 Introduction to C# Applications 2 What s in a name? That which we call a rose by any other name would smell as sweet. William Shakespeare When faced with a decision, I always ask, What would be the
More informationCOMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015
COMP-202: Foundations of Programming Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 Announcements Midterm Exams on 4 th of June (12:35 14:35) Room allocation will be announced soon
More informationCS 251 Intermediate Programming Java Basics
CS 251 Intermediate Programming Java Basics Brooke Chenoweth University of New Mexico Spring 2018 Prerequisites These are the topics that I assume that you have already seen: Variables Boolean expressions
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics
Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More informationCS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output
CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output Last revised January 12, 2006 Objectives: 1. To introduce arithmetic operators and expressions 2. To introduce variables
More informationTo start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer
C# Tutorial Create a Motivational Quotes Viewer Application in Visual Studio In this tutorial we will create a fun little application for Microsoft Windows using Visual Studio. You can use any version
More informationObject oriented lab /second year / review/lecturer: yasmin maki
1) Examples of method (function): Note: the declaration of any method is : method name ( parameters list ).. Method body.. Access modifier : public,protected, private. Return
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationBASIC ELEMENTS OF A COMPUTER PROGRAM
BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators
More informationTutorial 5 Completing the Inventory Application Introducing Programming
1 Tutorial 5 Completing the Inventory Application Introducing Programming Outline 5.1 Test-Driving the Inventory Application 5.2 Introduction to C# Code 5.3 Inserting an Event Handler 5.4 Performing a
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationThe name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.
Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationLECTURE 02 INTRODUCTION TO C++
PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION
More informationPROGRAMMING STYLE. Fundamentals of Computer Science I
PROGRAMMING STYLE Fundamentals of Computer Science I Documentation and Style: Outline Meaningful Names Comments Indentation Named Constants Whitespace Compound Statements Documentation and Style Most programs
More informationIntroduction. Introduction to OOP with Java. Lecture 01: Introduction to OOP with Java - AKF Sep AbuKhleiF -
Introduction to OOP with Java Instructor: AbuKhleif, Mohammad Noor Sep 2017 www.abukhleif.com Lecture 01: Introduction Instructor: AbuKhleif, Mohammad Noor Sep 2017 www.abukhleif.com AbuKhleiF - www.abukhleif.com
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationCS11 Java. Fall Lecture 1
CS11 Java Fall 2006-2007 Lecture 1 Welcome! 8 Lectures Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7-8 Lab Assignments Made available on Mondays Due one week later Monday, 12 noon
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:
Java Programming, Eighth Edition 2-1 Chapter 2 Using Data A Guide to this Instructor s Manual: We have designed this Instructor s Manual to supplement and enhance your teaching experience through classroom
More informationChapter 2. Ans. C (p. 55) 2. Which is not a control you can find in the Toolbox? A. Label B. PictureBox C. Properties Window D.
Chapter 2 Multiple Choice 1. According to the following figure, which statement is incorrect? A. The size of the selected object is 300 pixels wide by 300 pixels high. B. The name of the select object
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationIntroduction to.net, C#, and Visual Studio. Part I. Administrivia. Administrivia. Course Structure. Final Project. Part II. What is.net?
Introduction to.net, C#, and Visual Studio C# Programming Part I Administrivia January 8 Administrivia Course Structure When: Wednesdays 10 11am (and a few Mondays as needed) Where: Moore 100B This lab
More informationChapter 2: Introduction to C++
Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++
More informationIntroduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017
Introduction to OOP with Java Instructor: AbuKhleif, Mohammad Noor Sep 2017 Lecture 01: Introduction Instructor: AbuKhleif, Mohammad Noor Sep 2017 Instructor AbuKhleif, Mohammad Noor Studied Computer Engineer
More informationVariables and Functions. ROBOTC Software
Variables and Functions ROBOTC Software Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal numbers, and words Variable names follow the same
More informationPROGRAMMING FUNDAMENTALS
PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write
More informationCOMP 202 Java in one week
COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of
More informationCOMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015
COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015 Assignment Due Date Assignment 1 is now due on Tuesday, Jan 20 th, 11:59pm. Quiz 1 is
More informationLesson 2A Data. Data Types, Variables, Constants, Naming Rules, Limits. A Lesson in Java Programming
Lesson 2A Data Data Types, Variables, Constants, Naming Rules, Limits A Lesson in Java Programming Based on the O(N)CS Lesson Series License for use granted by John Owen to the University of Texas at Austin,
More informationVisual C# Instructor s Manual Table of Contents
Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms
More informationChapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley
More informationValues, Variables, Types & Arithmetic Expressions. Agenda
Values, Variables, Types & Arithmetic Expressions Lecture 2 Object-Oriented Programming Agenda Inside of a Computer Value Variable Data Types in Java Literals Identifiers Type conversions Manipulating
More informationCS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 05 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions / Comments? recap and some more details about variables, and if / else statements do lab work
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More informationComputers, Variables and Types. Engineering 1D04, Teaching Session 2
Computers, Variables and Types Engineering 1D04, Teaching Session 2 Typical Computer Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 1 An Abstract View of Computers Copyright 2006 David Das, Ryan Lortie,
More informationCS112 Lecture: Working with Numbers
CS112 Lecture: Working with Numbers Last revised January 30, 2008 Objectives: 1. To introduce arithmetic operators and expressions 2. To expand on accessor methods 3. To expand on variables, declarations
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More informationNow find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]
C# Tutorial - Create a Tic Tac Toe game with Working AI This project will be created in Visual Studio 2010 however you can use any version of Visual Studio to follow along this tutorial. To start open
More informationCS 112 Introduction to Programming
CS 112 Introduction to Programming Java Primitive Data Types; Arithmetic Expressions Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu
More informationAdmin. CS 112 Introduction to Programming. Recap: Java Static Methods. Recap: Decomposition Example. Recap: Static Method Example
Admin CS 112 Introduction to Programming q Programming assignment 2 to be posted tonight Java Primitive Data Types; Arithmetic Expressions Yang (Richard) Yang Computer Science Department Yale University
More informationStart Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.
Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK. Before you start - download the game assets from above or on MOOICT.COM to
More informationChapter 3 Syntax, Errors, and Debugging. Fundamentals of Java
Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different
More informationA very simple program. Week 2: variables & expressions. Declaring variables. Assignments: examples. Initialising variables. Assignments: pattern
School of Computer Science, University of Birmingham. Java Lecture notes. M. D. Ryan. September 2001. A very simple program Week 2: variables & expressions Variables, assignments, expressions, and types.
More informationCSIS 1624 CLASS TEST 6
CSIS 1624 CLASS TEST 6 Instructions: Use visual studio 2012/2013 Make sure your work is saved correctly Submit your work as instructed by the demmies. This is an open-book test. You may consult the printed
More informationAP Computer Science Unit 1. Writing Programs Using BlueJ
AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationLaboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information
Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationIntroduction to the course and basic programming concepts
Introduction to the course and basic programming concepts Lecture 1 of TDA 540 Object-Oriented Programming Jesper Cockx Fall 2018 Chalmers University of Technology Gothenburg University About the course
More informationC: How to Program. Week /Mar/05
1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers
More informationC++ Support Classes (Data and Variables)
C++ Support Classes (Data and Variables) School of Mathematics 2018 Today s lecture Topics: Computers and Programs; Syntax and Structure of a Program; Data and Variables; Aims: Understand the idea of programming
More informationCurriculum Map Grade(s): Subject: AP Computer Science
Curriculum Map Grade(s): 11-12 Subject: AP Computer Science (Semester 1 - Weeks 1-18) Unit / Weeks Content Skills Assessments Standards Lesson 1 - Background Chapter 1 of Textbook (Weeks 1-3) - 1.1 History
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
More informationLab 9: Creating a Reusable Class
Lab 9: Creating a Reusable Class Objective This will introduce the student to creating custom, reusable classes This will introduce the student to using the custom, reusable class This will reinforce programming
More information1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.
Gaddis: Starting Out with Python, 2e - Test Bank Chapter Two MULTIPLE CHOICE 1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical
More informationMODULE 02: BASIC COMPUTATION IN JAVA
MODULE 02: BASIC COMPUTATION IN JAVA Outline Variables Naming Conventions Data Types Primitive Data Types Review: int, double New: boolean, char The String Class Type Conversion Expressions Assignment
More information