Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Computer and Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
Introduction to Computer Programming in C
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
Datalogi A 1: 8/9. Book: Cay Horstmann: Big Java or Java Consepts.
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program.
GTECH 731 Lab Session 2 Lab 1 Review, Lab 2 Intro 9/6/10 Lab 1 Review Lab 2 Overview.
Lecture 2: An Introduction to J# and.NET. 2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 2-2 Objectives “Microsoft.NET is based on the.NET.
Getting Started Example ICS2O curriculum
C# Tutorial From C++ to C#. Some useful links Msdn C# us/library/kx37x362.aspxhttp://msdn.microsoft.com/en- us/library/kx37x362.aspx.
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
Chapter 1 Introduction to Visual Basic Programming and Applications 1 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta.
1 Programming Concepts Module Code : CMV6107 Class Contact Hours: 45 hours (Lecture 15 hours) (Laboratory/Tutorial 30 hours) Module Value: 1 Textbook:
Chapter 1 Introduction to Visual Basic Programming and Applications 1 Joshi R.G. Dept. of Computer Sci. YMA.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
IE 411/511: Visual Programming for Industrial Applications
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 2: Working with Visual.
Lecture 1 Programming in C# Introducing C# Writing a C# Program.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
Author: Loh Jianxiong Christopher Editors: Chua Jie Sheng, Li Mengran, Peh Shao Hong, Oo Theong Siang.
2. Introduction to the Visual Studio.NET IDE. Chapter Outline Overview of the Visual Studio.NET IDE Overview of the Visual Studio.NET IDE Menu Bar and.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
Lecture Set 1 Part C: Understanding Visual Studio and.NET – Applications, Solutions, Projects (no longer used – embedded in Lecture Set 2A)
Chapter 11 An Introduction to Visual Basic 2008 Why Windows and Why Visual Basic How You Develop a Visual Basic Application The Different Versions of Visual.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.
Programming Concept Chapter I Introduction to Java Programming.
Clement Allen, PhD Florida A&M University SUMMER 2006.
CSE 131 Computer Science 1 Module 1: (basics of Java)
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
JDS – VB.NET Skill Session Fall 2004 Presented by YUHAO LIN.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
Using the while-statement to process data files. General procedure to access a data file General procedure in computer programming to read data from a.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 2: Working with Visual.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
CSCI 115 Computer Programming Overview. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Week 1 Lecture 1 Slide 1 CP2028 Visual Basic Programming 2 “The VB Team” Copyright © University of Wolverhampton CP2028 Visual Basic Programming 2 v Week.
Chapter 1: Introduction to Computers and Programming.
DEPARTMENT OF COMPUTER SCIENCE Introduction to Visual Basic BCA 3 RD YR PRESENTED BY HASHIR UN NABI Dated:01/07/
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Chapter 1 Introduction to Visual Basic
Dive Into® Visual Basic 2010 Express
Assembler, Compiler, Interpreter
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
Variables and Arithmetic Operations
Lecture 3: The J# Language
Assembler, Compiler, Interpreter
Building Java Programs
IS 135 Business Programming
Presentation transcript:

Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#

“AP Computer Science with.NET and J#” Lecture 2: Procedural Programming in Java and J# Microsoft.NET Workshops for Teachers

2-3 MicrosoftAP Computer Science with.NET and J# Workshop Track LectureTopic 1Java — History, Philosophy, and Overview 2Procedural Programming in Java and J# 3Object-oriented Programming in Java and J# 4Primitive Types vs. Object References (==, equals, toString, and arrays) 5Writing Your Own Classes 6Keeping Track of Your Objects with the Collection Classes 7Algorithms and Algorithm Analysis 8Debugging and Exception Handling Collection Classes and Iteration 19Additional Resources and Ideas

2-4 MicrosoftAP Computer Science with.NET and J# Lecture — Objectives “Procedural programming is all about code — you solve a problem by focusing on the procedures you need to write, and the order in which you want these procedures to execute. While this is now considered an old- fashioned way of programming, it is still viewed by some as the best way to teach beginners to program. The good news is that Java supports procedural programming, albeit a but clumsily…” Topics: –Visual Studio 2005 –Procedural programming –A quick tour of Java [ Joe Hummel, Lake Forest College ]

2-5 MicrosoftAP Computer Science with.NET and J# Part 1 A Quick Introduction to Visual Studio 2005

2-6 MicrosoftAP Computer Science with.NET and J# Visual Studio 2005 Microsoft’s flagship integrated development environment (IDE) One environment for all forms of software development: –Application types: console, desktop, web, … –Languages: J#, C#, C++, Visual Basic, … Many versions are available: –Express editions — free! — target one language / application type –Standard edition for entry-level programmers (no database provided) –Professional edition for enterprise programmers (with database) –Team editions = professional edition + software engineering tools –

2-7 MicrosoftAP Computer Science with.NET and J# Example Let’s rewrite our “ Hello world! ” program using Visual Studio –A simple console-based application…

2-8 MicrosoftAP Computer Science with.NET and J# Step 1: Create new project…

2-9 MicrosoftAP Computer Science with.NET and J# Step 2: Select J#, console app, name, location

2-10 MicrosoftAP Computer Science with.NET and J# Step 3: Implement… Code the program in coding window –use solution explorer window for navigating between program files –if you lose these windows, make visible via “View” menu coding window solution explorer

2-11 MicrosoftAP Computer Science with.NET and J# Step 4: Run! Just press F5 and off we go! –or use Debug menu, or VCR-like "Play" button on the toolbar –Visual Studio’s titlebar changes to display “Running”

2-12 MicrosoftAP Computer Science with.NET and J# Demo! “Hello world” console app in Visual Studio 2005…

2-13 MicrosoftAP Computer Science with.NET and J# Oops — the “console” flash By default, Visual Studio does the following: –opens DOS-like console window –runs program –closes window –so all you see is a flash! Solution? Read from keyboard… public class Program { public static void main(String[] args) throws Exception { System.out.println("Hello world!"); System.in.read(); // keep console window open until user presses ENTER… } public class Program { public static void main(String[] args) throws Exception { System.out.println("Hello world!"); System.in.read(); // keep console window open until user presses ENTER… } we’ll explain later…

2-14 MicrosoftAP Computer Science with.NET and J# Powerful Visual Studio features… IntelliSense Overloading Background compilation –to name just a few…

2-15 MicrosoftAP Computer Science with.NET and J# IntelliSense! IntelliSense is a fantastic advance –context-sensitive programming aid –reduces programming errors –encourages experimentation and exploration –TAB or ENTER to accept, ESC to dismiss… System.o

2-16 MicrosoftAP Computer Science with.NET and J# Overloading Java allows multiple procedures under the same name –known as overloading –procedures must differ in their parameters –Visual Studio depicts as a scrollable list… System.out.println(

2-17 MicrosoftAP Computer Science with.NET and J# Background Compilation Visual Studio is error checking in the background Errors are often detected as soon as stop typing –denoted by underlining much like a spelling mistake…

2-18 MicrosoftAP Computer Science with.NET and J# Part 2 Procedural Programming in Java and J#

2-19 MicrosoftAP Computer Science with.NET and J# Thinking in Terms of Procedures Procedural programming is thinking in terms of tasks –functions that compute & return values –subroutines that perform 1 or more operations Examples –Compute square root –Sort a list of names –Find median value –Input an integer –Output the maximum value –Output the minimum value –…

2-20 MicrosoftAP Computer Science with.NET and J# Example A program to apply Pythagorean’s theorem (c 2 = a 2 + b 2 ) –Given 2 sides of a right triangle, compute the length of the 3 rd side import java.io.*; // gain access to Java library for keyboard input public class Program { public static void main(String[] args) throws Exception { double a, b, c; // local variables System.out.println("** Welcome to Pythagorean Program **"); System.out.println(); c = getLength("Please enter length of hypotenuse (or 0): "); a = getLength("Please enter length of one side (or 0): "); b = getLength("Please enter length of other side (or 0): "); solveForUnknown(a, b, c); // c^2 = a^2 + b^2 System.in.read(); // keep console window open until user presses ENTER… } import java.io.*; // gain access to Java library for keyboard input public class Program { public static void main(String[] args) throws Exception { double a, b, c; // local variables System.out.println("** Welcome to Pythagorean Program **"); System.out.println(); c = getLength("Please enter length of hypotenuse (or 0): "); a = getLength("Please enter length of one side (or 0): "); b = getLength("Please enter length of other side (or 0): "); solveForUnknown(a, b, c); // c^2 = a^2 + b^2 System.in.read(); // keep console window open until user presses ENTER… }

2-21 MicrosoftAP Computer Science with.NET and J# Demo! Pythagorean program…

2-22 MicrosoftAP Computer Science with.NET and J# getLength Function Prompts the user and returns the user’s input as a real # –Requires creation of a keyboard object –User’s input is a string, must be converted to a real number ( double ) // create object we need to read from the keyboard: public static BufferedReader keyboard = new BufferedReader( new InputStreamReader(System.in)); public static double getLength(String prompt) throws Exception { String input; double value; System.out.print(prompt); // prompt the user input = keyboard.readLine(); // read a line of input as a string value = Double.parseDouble(input); // convert input string to a real # return value; } // create object we need to read from the keyboard: public static BufferedReader keyboard = new BufferedReader( new InputStreamReader(System.in)); public static double getLength(String prompt) throws Exception { String input; double value; System.out.print(prompt); // prompt the user input = keyboard.readLine(); // read a line of input as a string value = Double.parseDouble(input); // convert input string to a real # return value; } return type

2-23 MicrosoftAP Computer Science with.NET and J# solveForUnknown Subroutine Applies Pythagorean theorem to solve for unknown: public static void solveForUnknown(double a, double b, double c) throws Exception { int numberUnknowns = 0; double length; if (a == 0.0) numberUnknowns++; if (b == 0.0) numberUnknowns++; if (c == 0.0) numberUnknowns++; if (numberUnknowns == 1) { if (c == 0.0) // we are solving for hypotenuse c = sqrt(a^2 + b^2): { length = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0)); } else // we are solving for one of the legs, a = sqrt(c^2 – b^2) or b = sqrt(c^2 – a^2): { if (a == 0.0) length = Math.sqrt(Math.pow(c, 2.0) - Math.pow(b, 2.0)); else length = Math.sqrt(Math.pow(c, 2.0) - Math.pow(a, 2.0)); } System.out.println("length of unknown side = " + length); } else System.out.println("Sorry, you need to specify exactly 1 unknown value."); } public static void solveForUnknown(double a, double b, double c) throws Exception { int numberUnknowns = 0; double length; if (a == 0.0) numberUnknowns++; if (b == 0.0) numberUnknowns++; if (c == 0.0) numberUnknowns++; if (numberUnknowns == 1) { if (c == 0.0) // we are solving for hypotenuse c = sqrt(a^2 + b^2): { length = Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0)); } else // we are solving for one of the legs, a = sqrt(c^2 – b^2) or b = sqrt(c^2 – a^2): { if (a == 0.0) length = Math.sqrt(Math.pow(c, 2.0) - Math.pow(b, 2.0)); else length = Math.sqrt(Math.pow(c, 2.0) - Math.pow(a, 2.0)); } System.out.println("length of unknown side = " + length); } else System.out.println("Sorry, you need to specify exactly 1 unknown value."); } no return type (subroutines do not return a value)

2-24 MicrosoftAP Computer Science with.NET and J# Summary Procedural programming is all about code –Writing subroutines and functions –Specifying their execution order Java provides decent support for procedural programming –though keywords can be daunting at first ( static, void, …) Visual Studio provides excellent support –IDE makes quick work of building applications, once you learn Java :-)

2-25 MicrosoftAP Computer Science with.NET and J# Resources Web site for slides, demos, associated lab exercises: – – –

2-26 MicrosoftAP Computer Science with.NET and J# That’s it! Next up: LectureTopic.. 3Object-oriented Programming in Java and J#......