Cleveland State University. Lecture Notes Feb Iteration Arrays ArrayLists. V. Matos
|
|
- Randall Ellis
- 5 years ago
- Views:
Transcription
1 Cleveland State University IST311 V. Matos Lecture Notes Feb Iteration Arrays ArrayLists Observe that various ideas discussed in class are given as separate code fragments in one large file. You need to toggle comments to execute the different portions of these notes. ITERATION ARRAYS. Chapter SAMPLE #1 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Looping1 class Program static void Main(string[] args) // reading three-digits data from the system's keyboard // (data set ends with -1) // Find max, min, and average int data = 0; string strdata; int samplemax = -1; int samplemin= 1000; int sampleaccumulator = 0; int samplesize = 0; double sampleavg = 0; while (data!= -1) Console.WriteLine("Enter a number [-1 to END]"); strdata = Console.ReadLine(); data = int.parse(strdata); if ((data >= 0) && (data <= 999)) samplesize++; sampleaccumulator += data; //choosing MINIMUM value if (data < samplemin) samplemin = data; //choosing MAXIMUM if (data > samplemax) samplemax = data; else String msg = data == -1? "" : "Invalid data"; Console.WriteLine(msg);
2 //while //showing results if (samplesize > 0) Console.WriteLine("Max value: " + samplemax); Console.WriteLine("Min value: " + samplemin); Console.WriteLine("Avg value: " + (double)sampleaccumulator/samplesize); Console.WriteLine("Done..."); Console.ReadLine(); SAMPLE #2 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Looping2 class Program static void Main(string[] args) // different forms of the for loop int j = 3; for (int i1 = 0; i1 <= j; i1++) Console.WriteLine("i= 0 j=1", i1, j); // //int i2 = 0; //for ( ; i2 <= 3; i2++) // // Console.WriteLine("i2= 0 ", i2 ); // // //int i3 = 0; //for (; true ; ) // // Console.WriteLine("i3= 0 ", i3++); // if (i3 > 4) break; // Console.WriteLine("Done..."); Console.ReadLine(); //main //program
3 ARRAYS CHAPTER 7. Arrays & List Arrays using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; namespace Arrays1 class Program static void Main(string[] args) //// //int[] a = new int[3]; //a[0] = 11; //a[1] = 22; //a[2] = 33; ////a[4] = 44; // // // Console.WriteLine("a[0]= 1", i, a[i]); // //// //int[] b = new int[] 111, 222, 333, 444 ; //for (int i = 0; i < b.length; i++) // // Console.WriteLine("b[0]= 1", i, b[i]); // ////is the following a mistake? ////Console.WriteLine( b[4] ); ////is the following a mistake? ////int i = 3; ////// ////enter n values. compute avg and difference to avg. //double accumulator = 0.0; //int n = 5; //int[] c = new int[5]; //for (int i = 0; i < c.length; i++) // // Console.WriteLine("Enter a number"); // c[i] = Convert.ToInt32(Console.ReadLine()); // accumulator += c[i]; // //double avg = (double)accumulator / n; //Console.WriteLine("Average is: " + avg); //for (int i = 0; i < c.length; i++) // // Console.WriteLine("0\t1\t2", i, c[i], (c[i] - avg)); // //// //// testing foreach loop //int[] b = new int[] 111, 222, 333, 444 ; //foreach (int x in b) // // Console.WriteLine("foreach loop. " + x);
4 // // //copying from one array to another (to discuss later) //int[] d = new int[] 22, 11, 33, 44 ; //int[] e = new int[d.length]; //e = d; // this is a SHALLOW copy //foreach (int x in e) Console.WriteLine("Shallow1 " + x); //d[3] = 44444; //foreach (int x in e) Console.WriteLine("Shallow2 " + x); //for (int i = 0; i < d.length; i++) // // e[i] = d[i]; //this is a DEEP copy // //foreach (int x in e) Console.WriteLine("Deep1 " + x); //d[3] = ; //foreach (int x in e) Console.WriteLine("Deep2 " + x); //// ////using methods in the Array Class (sorting searching...) //int[] f = new int[] 55, 33, 11, 22, 44 ; //Console.WriteLine("\nArray Data"); //foreach (int x in f) Console.Write("\t" + x); //Array.Sort(f); //Console.WriteLine("\nArray.Sort"); //foreach (int x in f) Console.Write("\t" + x); //Array.Reverse(f); //Console.WriteLine("\nArray.Reverse"); //foreach (int x in f) Console.Write("\t" + x); //Console.WriteLine("\nArray.Index of 22: " + Array.IndexOf(f, 22)); //Console.WriteLine("\nArray.Index of 99: " + Array.IndexOf(f, 99)); //int[] g = new int[f.length]; //Array.Copy(f, g, f.length); //this is a DEEP copy //Console.WriteLine("\nArray.Copy1"); //foreach (int x in g) Console.Write("\t" + x); //f[0] = ; //Console.WriteLine("\nArray.Copy2"); //foreach (int x in g) Console.Write("\t" + x); ////Array.Clear(g, 0, g.length); ////Console.WriteLine("\nArray.Clear"); ////foreach (int x in g) Console.Write("\t" + x); //// ////passing an array as a parameter (byreference) //int[ ] h = new int[ ] 55, 33, 11, 22, 44 ; //MyNiceArrayDisplay(h); //foreach (int x in h) // Console.WriteLine(x); //// ////passing an array as a parameter (byreference) & method changing data
5 //int[] m = new int[] 55, 33, 11, 22, 44 ; //Console.WriteLine("[Main] Array Before calling Method"); //foreach (int x in m) Console.Write("\t" + x); //int b = 5; //MyMethodChanger(m, b); //Console.WriteLine("[Main] Array After calling Method"); //foreach (int x in m) Console.Write("\t" + x); //Console.WriteLine(); //Console.WriteLine("Value of b: " + b); // //passing an array as a parameter (byreference) & method returning data //int[ ] n = new int[ ] 55, 33, 11, 22, 44 ; //int searchvalue = 99; //int location = MyFindDataInArrayMethod(n, searchvalue); //Console.WriteLine("Value 0 at Location: 1", searchvalue, location); //for(int i = 0; i <n.length; i++) // Console.WriteLine("Loc 0: 1", i, n[i]); //try int searchvalue = 99; //// //// count ODD numbers //int[ ] n = new int[ ] 55, 33, 11, 22, 44 ; //int countodd = MyCountOddMethod(n); //Console.WriteLine("There are 0 ODD numbers in the array", countodd); //for (int i = 0; i < n.length; i++) // Console.WriteLine("Loc 0: 1", i, n[i]); // // count how many numbers below the array's average, return percent value int[] n = new int[] 55, 33, 11, 22, 44 ; double pctbelow = MyBelowAvgMethod(n); Console.WriteLine("Percentage of cells below avg is 0", pctbelow); for (int i = 0; i < n.length; i++) Console.WriteLine("Loc 0: 1", i, n[i]); //// //// two dimensional arrays //int[,] golfstrokes1 = new int[18, 2]; //RECTANGULAR (strokes,putts) //int[,] scoreboard = new int[,] 25, 33, 48, 62, 69, 78, 82, 101 ; //scoreboard[3, 0] = 82; //accessing cells of RECTANGULAR array //scoreboard[3, 1] = 101; //for (int row=0; row<4; row++) // // Console.Write("\nQuarter 0 ", row);
6 // for(int col=0; col<2; col++) // // Console.Write("\t" + scoreboard[row, col]); // // //// //int[ ][ ] calories = new int[7][ ]; //JAGGED array //calories[0] = new int[ ] 900, 1200, 1000 ; //calories[1] = new int[ ] 800, 1800 ; //calories[2] = new int[ ] 5000 ; //calories[3] = new int[ ] 900, 1300, 1400 ; //calories[4] = new int[ ] 800, 1100 ; //calories[5] = new int[ ] 950, 1400 ; //calories[6] = new int[ ] 1200, 1000, 1800 ; //calories[6][0] = 1200; //accessing cells of JAGGED array ////calories[6, 0] = 1200; //invalid statement //for (int row = 0; row < 7; row++) // // Console.Write("\nCalories-Day 0", row); // foreach( int x in calories[row] ) // // Console.Write("\t0", x); // // ////using the Rank method to determine the array's dimension //Console.WriteLine("\n"); //Console.WriteLine("Calories.RANK " + calories.rank); //Console.WriteLine("Calories.GETLENGHT(0) " + calories.getlength(0) ); //Console.WriteLine("\n"); //Console.WriteLine("scoreBoard.RANK " + scoreboard.rank); //Console.WriteLine("scoreBoard.GETLENGHT(0) " + scoreboard.getlength(0)); //Console.WriteLine("scoreBoard.GETLENGHT(1) " + scoreboard.getlength(1)); //// //// ArrayList (Dynamic arrays) //// ADD: using System.Collections; //// Creates and initializes a new ArrayList. //ArrayList myal = new ArrayList(); //myal.add("hello"); //myal.add("wonderful"); //myal.add("world"); //myal.add("!"); //myal.add("adios"); //myal.add(123); //myal.add(1); //// Displays the properties and values of the ArrayList. //Console.WriteLine("myAL ArrayList"); //Console.WriteLine("\tCount: 0", myal.count); //Console.WriteLine("\tCapacity: 0", myal.capacity); //Console.WriteLine("\tValues:"); //for (int i = 0; i < myal.count; i++) // // Console.WriteLine("\t0: 1 \t\ttype: 2", // i, myal[i], myal[i].gettype()); // //Console.WriteLine("\t0: 1 " // // + (myal[i].tostring().length<4?"\t\t":"\t") // // + " Type: 2", // // i, myal[i], myal[i].gettype());
7 // //Console.WriteLine("Contains World: " + myal.contains("world")); //Console.WriteLine("IndexOf World: " + myal.indexof("world")); //Console.WriteLine("After Insert"); //myal.insert(2, "blue"); //for (int i = 0; i < myal.count; i++) // // Console.WriteLine("\t0: 1 ", i, myal[i]); // //Console.WriteLine("After Remove"); //myal.remove("wonderful"); //for (int i = 0; i < myal.count; i++) // // Console.WriteLine("\t0: 1 ", i, myal[i]); // //Console.WriteLine("After RemoveAt last"); //myal.removeat(myal.count - 1); //for (int i = 0; i < myal.count; i++) // // Console.WriteLine("\t0: 1 ", i, myal[i]); // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // STRINGS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //String str1 = "Hello woderful world"; //String str2 = ""; //String str3; //String str4 = "Hello WONDERFUL World"; //Console.WriteLine("\nstr1 is: 0", str1); //Console.WriteLine("str1 Length: 0", str1.length ); //Console.WriteLine("str1 first char: 0", str1[0] ); //Console.WriteLine("str1 last char: 0", str1[ str1.length-1 ] ); //Console.WriteLine("str1 IndexOf(a): 0", str1.indexof("a") ); //Console.WriteLine("str1 IndexOf(u): 0", str1.indexof("u")); //Console.WriteLine("str1 LastIndexOf(o): 0", str1.lastindexof("o")); //Console.WriteLine("str1.Replace : 0", str1.replace("world", "mundo")); //Console.WriteLine("str1 Substring: 0", str1.substring(7, 3) ); //string[] tokens = str1.split(); //Console.WriteLine("Number of tokens after Split() 0", tokens.length); //for (int i=0; i < tokens.length; i++) // Console.WriteLine("After Split - tokens[0]= 1", i, tokens[i] ); //String strwithmanyblanks = " Adios amigos "; //Console.WriteLine("strWithManyBlanks: *0* \n After Trimming: *1*", // strwithmanyblanks, strwithmanyblanks.trim() ); //Console.WriteLine("ToUpper: 0", strwithmanyblanks.toupper() ); // //assignment //str2 = str1; //Console.WriteLine("\nstring str2= 0", str2); ////comparison (remember == does not work for strings) //if (str1.compareto(str4) == 0) // Console.WriteLine("0 -is greather than- 1", str1, str4); //else // Console.WriteLine("0 -is greather than- 1", str4, str1);
8 //Console.WriteLine(".compareTo(...) value is: " + str1.compareto(str4)); // Console.WriteLine("\nDone..."); Console.ReadLine(); //main // private static void MyNiceArrayDisplay (int[ ] a) Console.WriteLine("cell[0]= 1", i, a[i]); a[i] += 10; // private static void MyMethodChanger(int[ ] a, int b) Console.WriteLine("\n[Method] Array received by the subroutine"); Console.Write("\t" + a[i]); a[i] += 10; //each array cell is changed b = 1000; Console.WriteLine(); // public static int MyFindDataInArrayMethod(int[] m, int valuetobefound) for (int i = 0; i < m.length; i++) if (m[i] == valuetobefound) return i; return -1; // // counting odd numbers in an array public static int MyCountOddMethod(int[] a) int accum = 0; if (a[i] % 2 == 1 ) accum++; return accum; // // percent of values below avg public static double MyBelowAvgMethod(int[] a) int accum = 0; accum = +a[i]; double avg = (double) accum / a.length; int countbelow = 0; if (a[i] < avg) countbelow++;
9 return (double)(countbelow / a.length); // NEEDS TO BE FIXED??? //program
PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science And Engineering
INTERNAL ASSESSMENT TEST 1 Date : 19 08 2015 Max Marks : 50 Subject & Code : C# Programming and.net & 10CS761 Section : VII CSE A & C Name of faculty : Mrs. Shubha Raj K B Time : 11.30 to 1PM 1. a What
More informationIST311 Chapter13.NET Files (Part2)
IST311 Chapter13.NET Files (Part2) using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text;
More informationArrays. Structure programming. Section-(6) Array Initialization. <Type> [] identifier;
El-Shorouk Academy Acad. Year : 2013 / 2014 Higher Institute for Computer & Term : Second Information Technology Year : First Department of Computer Science [] identifier; Structure programming
More informationProblem Statement. A1: being lapped on the track
Problem Statement A1: being lapped on the track You and your friend are running laps on the track at the rec complex. Your friend passes you exactly X times in one of your laps (that is, you start the
More informationProblem Statement. B1: average speed
Problem Statement B1: average speed A woman runs on tracks of different lengths each day. She always times the last lap. Use the time for the last lap (in seconds) and the length of the track (in miles)
More informationArrays and Collections. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies
7 Arrays and Collections C# Programming: From Problem Analysis to Program Design 2nd Edition David McDonald, Ph.D. Director of Emerging Technologies Chapter Objectives Learn array basics Declare arrays
More informationWhat property of a C# array indicates its allocated size? What keyword in the base class allows a method to be polymorphic?
What property of a C# array indicates its allocated size? a. Size b. Count c. Length What property of a C# array indicates its allocated size? a. Size b. Count c. Length What keyword in the base class
More information1. What is the difference between a compiler and an interpreter? Also, discuss Java s method.
Name: Write all of your responses on these exam pages. 1 Short Answer (5 Points Each) 1. What is the difference between a compiler and an interpreter? Also, discuss Java s method. 2. Java is a platform-independent
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 information-.Net Lab Programs Index S.no. Particulars Page no Write a Program in C# to demonstrate Command line arguments processing.
Index S.no. Particulars Page no 1 Write a Program in C# to check whether a number is Palindrome or not. 6 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Write a Program in C# to demonstrate Command line arguments
More informationLab - 1. Solution : 1. // Building a Simple Console Application. class HelloCsharp. static void Main() System.Console.WriteLine ("Hello from C#.
Lab - 1 Solution : 1 // Building a Simple Console Application class HelloCsharp static void Main() System.Console.WriteLine ("Hello from C#."); Solution: 2 & 3 // Building a WPF Application // Verifying
More informationConsole.ReadLine(); }//Main
IST 311 Lecture Notes Chapter 13 IO System using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading.Tasks;
More informationGeneral Certificate of Education Advanced Subsidiary Examination June 2010
General Certificate of Education Advanced Subsidiary Examination June 2010 Computing COMP1/PM/C# Unit 1 Problem Solving, Programming, Data Representation and Practical Exercise Preliminary Material A copy
More informationCleveland State University. CIS260 Lecture Notes Feb 22 Chapter 6 Iterations Files (updated Wed. Mar 3) V. Matos
Cleveland State University CIS260 Lecture Notes Feb 22 Chapter 6 Iterations Files (updated Wed. Mar 3) V. Matos Observe that various ideas discussed in class are given as separate code fragments in one
More informationExercises Software Development I. 06 Arrays. Declaration, Initialization, Usage // Multi-dimensional Arrays. November 14, 2012
Exercises Software Development I 06 Arrays Declaration, Initialization, Usage // Multi-dimensional Arrays November 4, 202 Software Development I Winter term 202/203 Institute for Pervasive Computing Johannes
More informationLesson07-Arrays-Part4. Program class. namespace Lesson07ArraysPart4Prep { class Program { static double METER_TO_INCHES = 100 / 2.
Lesson07-Arrays-Part4 Program class namespace Lesson07ArraysPart4Prep class Program static double METER_TO_INCHES = 100 / 2.54; static void Main(string[] args) Experiment01(); //Tuples Experiment02();
More informationUnit-III Eduoncloud.com Programming using C#.&.NET
C# Programming With.NET (06CS/IS761) Chapter wise questions appeared in previous years: Markes & Year Appeared UNIT III: C# Language Fundamentals 1 Why System.Object is called master node? List and explain
More information// Program 4 // CIS // Due: 4/12/2015 // By: Ben Spalding
// Program 4 // CIS 200-01 // Due: 4/12/2015 // By: Ben Spalding //This program was created to use the Icomparer and IComparable interfaces to sort objects of the library item class // the sorts are at
More informationThis page intentionally left blank
This page intentionally left blank Arrays and References 391 Since an indexed variable of the array a is also a variable of type double, just like n, the following is equally legal: mymethod(a[3]); There
More informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
More informationA1 Problem Statement Willie s Push-ups
A1 Problem Statement Willie s Push-ups After every football score, Willie the Wildcat does one push-up for every point scored so far in the current game. On the scoreboard at the stadium, there is displayed
More informationFall Semester (081) Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals
INTERNET PROTOCOLS AND CLIENT-SERVER PROGRAMMING Client SWE344 request Internet response Fall Semester 2008-2009 (081) Server Module 2.1: C# Programming Essentials (Part 1) Dr. El-Sayed El-Alfy Computer
More informationRegEx - Numbers matching. Below is a sample code to find the existence of integers within a string.
RegEx - Numbers matching Below is a sample code to find the existence of integers within a string. Sample code pattern to check for number in a string: using System; using System.Collections.Generic; using
More informationString sequence of characters string Unicode Characters immutable they cannot be changed after they have been created.
String A string is basically a sequence of characters A string in C# is an object of type String The string type represents a string of Unicode Characters. String objects are immutable that is they cannot
More informationRegEx-validate IP address. Defined below is the pattern for checking an IP address with value: String Pattern Explanation
RegEx-validate IP address Defined below is the pattern for checking an IP address with value: 240.30.20.60 String Pattern Explanation 240 ^[0-9]1,3 To define the starting part as number ranging from 1
More informationAP CS Unit 7: Arrays Exercises
AP CS Unit 7: Arrays Exercises 1. What is displayed? int [] a = new int[ 3 ]; System.out.println(a.length ); 2. What is displayed? int [] sting = { 34, 23, 67, 89, 12 ; System.out.println( sting[ 1 ] );
More information- Thus there is a String class (a large class)
Strings - Strings in Java are objects - Thus there is a String class (a large class) - In a statement like this: System.out.println( Hello World ); the Java compiler creates a String object from the quoted
More informationGradeBook code. Main Program
// Program 4 // CIS 199-01/-76 // Due: Tuesday April 20 by class // By: Charles Rady GradeBook code Main Program // File: Program.cs // This file serves as a simple test program for the gradebook class.
More informationArray Structure. In C#, arrays can be declared as fixed length or dynamic. A fixed length array can store a predefined number of items.
Array Structure Programming C# is a new self-taught series of articles, in which I demonstrate various topics of C# language in a simple step by step tutorial format. Arrays are probably one of the most
More informationArrays, Strings and Collections
Arrays Arrays can be informally defined as a group of variables containing values of the same type and that in some way or another they are related. An array has a fixed size that is defined before the
More informationCS 231 Data Structures and Algorithms Fall Arrays Lecture 07 - September 19, Prof. Zadia Codabux
CS 231 Data Structures and Algorithms Fall 2018 Arrays Lecture 07 - September 19, 2018 Prof. Zadia Codabux 1 Agenda Arrays For Each Loop 2D Arrays 2 Administrative None 3 Arrays 4 Array Data structure
More informationDepartment of Networks College of Bardarash Technical Institute DUHOK Polytechnic University Subject: Programming Fundamental by JAVA Course Book
1 Department of Networks College of Bardarash Technical Institute DUHOK Polytechnic University Subject: Programming Fundamental by JAVA Course Book Year 1 Lecturer's name: MSc. Sami Hussein Ismael Academic
More informationOccupied versus Unoccupied
A1 Problem Statement Occupied versus Unoccupied Most houses have an electricity meter that records the amount of electricity that has been used since the meter was installed. This is typically recorded
More informationCS 170 Exam 2. Section 004 Fall Name (print): Instructions:
CS 170 Exam 2 Section 004 Fall 2013 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than
More informationThis is an open-book test. You may use the text book Be Sharp with C# but no other sources, written or electronic, will be allowed.
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 124 DATE: 1 September 2014 TIME: 3 hours MARKS: 105 ASSESSORS: Prof. P.J. Blignaut BONUS MARKS: 3 MODERATOR: Dr. L. De Wet
More informationCOE 212 Engineering Programming. Welcome to the Final Exam Tuesday December 15, 2015
1 COE 212 Engineering Programming Welcome to the Final Exam Tuesday December 15, 2015 Instructors: Dr. Salim Haddad Dr. Bachir Habib Dr. Joe Tekli Dr. Wissam F. Fawaz Name: Student ID: Instructions: 1.
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 Objects and classes: Basics of object and class in C#. Private and public members and protected. Static
More informationESC101 : Fundamental of Computing
ESC101 : Fundamental of Computing End Semester Exam 19 November 2008 Name : Roll No. : Section : Note : Read the instructions carefully 1. You will lose 3 marks if you forget to write your name, roll number,
More informationCollect the Raw Materials
APPENDIX A Fundamentals C# is an object-oriented language. It has many similarities with Java, C++, and Visual Basic. Programmers often say that when the power and efficiency of C++ shook hands with the
More informationLAB 9 Arrays. Topics. Array of data types Accessing array elements Initializing array elements
LAB 9 Arrays Topics Array of data types Accessing array elements Initializing array elements Array of data types An array is an indexed collection of objects, all of the same type. We can declare a C#
More informationAdvanced Programming C# Lecture 2. dr inż. Małgorzata Janik
Advanced Programming C# Lecture 2 dr inż. Małgorzata Janik majanik@if.pw.edu.pl Winter Semester 2017/2018 C# Classes, Properties, Controls Constructions of Note using namespace like import in Java: bring
More informationEngr 123 Spring 2018 Notes on Visual Studio
Engr 123 Spring 2018 Notes on Visual Studio We will be using Microsoft Visual Studio 2017 for all of the programming assignments in this class. Visual Studio is available on the campus network. For your
More informationObjectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments
Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify
More informationChapter 6: Using Arrays
Chapter 6: Using Arrays Declaring an Array and Assigning Values to Array Array Elements A list of data items that all have the same data type and the same name Each item is distinguished from the others
More information204111: Computer and Programming
204111: Computer and Programming Week 4: Control Structures t Monchai Sopitkamon, Ph.D. Overview Types of control structures Using selection structure Using repetition structure Types of control ol structures
More informationB1 sprinkler coverage. Problem Statement
B1 sprinkler coverage Problem Statement There will be two irrigation sprinklers located at opposite corners of a field. Assume that each sprinkler covers a quarter of a circle. Assume that the field is
More informationDC69 C# and.net JUN 2015
Solutions Q.2 a. What are the benefits of.net strategy advanced by Microsoft? (6) Microsoft has advanced the.net strategy in order to provide a number of benefits to developers and users. Some of the major
More informationThe data in the table are arranged into 12 rows and 12 columns. The process of printing them out can be expressed in a pseudocode algorithm as
Control structures in Java are statements that contain statements. In particular, control structures can contain control structures. You've already seen several examples of if statements inside loops,
More informationCS201 Discussion 7 MARKOV AND RECURSION
CS201 Discussion 7 MARKOV AND RECURSION Before we begin Any questions about the midterm solutions? Making a Markov Map Recall that in Markov, we re trying to make a map of all k-grams to all k-grams that
More information1 Short Answer (10 Points Each)
COSC 117 Exam # Solutions Fall 01 1 Short Answer (10 Points Each) 1. Write a declaration for a two dimensional array of doubles that has 1 rows and 17 columns. Then write a nested for loop that populates
More information11. Collections of Objects
11. Collections of Objects 1 Arrays There are three issues that distinguish arrays from other types of containers: efficiency, type, and the ability to hold primitives. When you re solving a more general
More informationComputer Science is...
Computer Science is... Machine Learning Machine learning is the study of computer algorithms that improve automatically through experience. Example: develop adaptive strategies for the control of epileptic
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 String and files: String declaration and initialization. Strings and Char Arrays: Properties And Methods.
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 Pointers: Pointer declaration and initialization. Pointer To Pointer. Arithmetic operation on pointer
More information6: Arrays and Collections
6: Arrays and Collections Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and
More informationFull file at
Chapter 1 Primitive Java Weiss 4 th Edition Solutions to Exercises (US Version) 1.1 Key Concepts and How To Teach Them This chapter introduces primitive features of Java found in all languages such as
More information1 Short Answer (15 Points Each)
Name: Write all of your responses on these exam pages. If you need extra space please use the backs of the pages. 1 Short Answer (15 Points Each) 1. Write the following Java declarations, (a) A double
More informationGetting started with Java
Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly
More informationChapter 6. Arrays. Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays
Chapter 6 Arrays Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays Chapter 6 Java: an Introduction to Computer Science & Programming
More informationDealing with Output. Producing Numeric Output CHAPTER 3. Task. Figure 3-1. The program in action
CHAPTER 3 You already know all the main steps that you should take when developing a program in the C# language. In addition, you have already seen the important statement Console. WriteLine, which displays
More informationBapatla Engineering College::Bapatla II/IV B.Tech(supplementary)Degree examination November 2016
1. Answer all questions. 1x12=1 a. List important features of C#. (1M) 1. Simple 2. Modern 3. Object oriented 4. Type safe 5. Interoperability b. Describe Call Method. (1M) If we want to call an instance
More informationMethod OverLoading printf method Arrays Declaring and Using Arrays Arrays of Objects Array as Parameters
Outline Method OverLoading printf method Arrays Declaring and Using Arrays Arrays of Objects Array as Parameters Variable Length Parameter Lists split() Method from String Class Integer & Double Wrapper
More informationComputer Science E-119 Fall Problem Set 1. Due before lecture on Wednesday, September 26
Due before lecture on Wednesday, September 26 Getting Started Before starting this assignment, make sure that you have completed Problem Set 0, which can be found on the assignments page of the course
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II
CS313D: ADVANCED PROGRAMMING LANGUAGE Lecture 3: C# language basics II Lecture Contents 2 C# basics Methods Arrays Methods 3 A method: groups a sequence of statement takes input, performs actions, and
More information6: Arrays and Collections
6: Arrays and Collections Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.
More informationArrays. Chapter 6. Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays
Chapter 6 Arrays Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays Chapter 6 Java: an Introduction to Computer Science & Programming
More informationQuestion: Total Points: Score:
CS 170 Exam 2 Section 002 Fall 2013 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than
More informationAdministrative Stuff CIS Last Time. Midterm 2 today in-lab this week dups. Assignment 10. November 27, 2018
Administrative Stuff CIS 1068 November 27, 2018 Midterm 2 today in-lab this week dups Assignment 10 Last Time our SmartArray ArrayList ArrayList useful no need to memorize. add to cheat sheet Generics.
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Arrays A data structure for a collection of data that is all of the same data type. The data type can be
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 214 MODULE TEST 1
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 214 MODULE TEST 1 DATE: 12 March 2014 TIME: 4 hours MARKS: 220 ASSESSORS: Prof. P.J. Blignaut & Mr G.J. Dollman BONUS MARKS:
More information2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17
CS313D: ADVANCED PROGRAMMING LANGUAGE Lecture 3: C# language basics II Lecture Contents 2 C# basics Methods Arrays 1 Methods : Method Declaration: Header 3 A method declaration begins with a method header
More information1 Short Answer (10 Points Each)
Name: Write all of your responses on these exam pages. 1 Short Answer (10 Points Each) 1. What is the difference between a compiler and an interpreter? Also, discuss how Java accomplishes this task. 2.
More informationCIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION
CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1 Name SOLUTION Page Points Score 2 15 3 8 4 18 5 10 6 7 7 7 8 14 9 11 10 10 Total 100 1 P age 1. Program Traces (41 points, 50 minutes)
More informationCIS November 27, 2018
CIS 1068 November 27, 2018 Administrative Stuff Midterm 2 today in-lab this week dups Assignment 10 Last Time our SmartArray ArrayList ArrayList useful no need to memorize. add to cheat sheet Generics.
More informationA method is a code block that contains a series of statements. Methods. Console.WriteLine(); Console.ReadKey(); Console.ReadKey(); int.
A method is a code block that contains a series of statements Methods Built-in User Define Built-in Methods (Examples): Console.WriteLine(); int.parse(); Methods Void (Procedure) Return (Function) Procedures
More informationIt is a constructor and is called using the new statement, for example, MyStuff m = new MyStuff();
COSC 117 Exam 3 Key Fall 2012 Part 1: Definitions & Short Answer (3 Points Each) 1. A method in a class that has no return type and the same name as the class is called what? How is this type of method
More informationUniversity of Palestine. Mid Exam Total Grade: 100
First Question No. of Branches (5) A) Choose the correct answer: 1. If we type: system.out.println( a ); in the main() method, what will be the result? int a=12; //in the global space... void f() { int
More information1 Short Answer (5 Points Each)
1 Short Answer (5 Points Each) 1. Write a declaration of an array of 300 strings. String strarray[] = new String[300];. Write a method that takes in an integer n as a parameter and returns one half of
More informationCT 229 Arrays Continued
CT 229 Arrays Continued 20/10/2006 CT229 Lab Assignments Current lab assignment is due today: Oct 20 th Before submission make sure that the name of each.java file matches the name given in the assignment
More informationINFORMATICS LABORATORY WORK #2
KHARKIV NATIONAL UNIVERSITY OF RADIO ELECTRONICS INFORMATICS LABORATORY WORK #2 SIMPLE C# PROGRAMS Associate Professor A.S. Eremenko, Associate Professor A.V. Persikov 2 Simple C# programs Objective: writing
More informationCSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2013
CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2013 Name: This exam consists of 7 problems on the following 6 pages. You may use your single- side hand- written 8 ½ x 11 note sheet during the
More informationIntermediate Programming
Intermediate Programming Lecture 12 Interfaces What is an Interface? A Java interface specified a set of methods that any class that implements the interfacesmust have. An Interface is a type, which means
More informationBuilding Applications
V B. N E T P r o g r a m m i n g, T h e B a s i c C o n c e p t s a n d To o l s E n g. H a s a n A l h o u r i Building Applications analyzing designing coding testing deploying Eng. Hasan Alhouri 1 Programming
More informationHST 952. Computing for Biomedical Scientists Lecture 5
Harvard-MIT Division of Health Sciences and Technology HST.952: Computing for Biomedical Scientists HST 952 Computing for Biomedical Scientists Lecture 5 Outline Recursion and iteration Imperative and
More informationC# Programming Tutorial Lesson 1: Introduction to Programming
C# Programming Tutorial Lesson 1: Introduction to Programming About this tutorial This tutorial will teach you the basics of programming and the basics of the C# programming language. If you are an absolute
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 24 March 18, 2016 The Java ASM What is the value of ans at the end of this program? Counter[] a = { new Counter(), new Counter() ; Counter[] b = {
More informationCS 170 Exam 2. Version: A Fall Name (as in OPUS) (print): Instructions:
CS 170 Exam 2 Version: A Fall 2015 Name (as in OPUS) (print): Section: Seat Assignment: Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do
More informationUsed to write.net software Software that targets the.net Framework is called managed code
Learning C# What is C# A new object oriented language Syntax based on C Similar to C++ and Java Used to write.net software Software that targets the.net Framework is called managed code C# gains much from
More informationMidterm 2 A. 10 Questions. While some questions may seem familiar to practice problems, there are likely to be subtle
Name email Midterm 2 A 10 Questions. While some questions may seem Midterm familiar 2 to A practice problems, there are likely to be subtle 10 Questions. While some questions may seem familiar to practice
More informationExpression: Expression: Statement: Output: Expression: Expression:
CS 149: Programming Fundamentals Written Exam #2 James Madison University Fall 2015 This work complies with the JMU Honor Code. I have neither given nor received unauthorized assistance, and I will not
More informationArrays and Array Lists. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos and Alexandra Stefan University of Texas at Arlington
Arrays and Array Lists CSE 1310 Introduction to Computers and Programming Vassilis Athitsos and Alexandra Stefan University of Texas at Arlington 1 Motivation Current limitation: We cannot record multiple
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 informationARRAYS. Java Programming
5 ARRAYS 144 Objectives Declare and create arrays of primitive, class, or array types Explain why elements of an array are initialized Given an array definition, initialize the elements of an array Determine
More informationArrays. Chapter 6. Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays
Chapter 6 Arrays Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays Chapter 6 Java: an Introduction to Computer Science & Programming
More informationx = 3 * y + 1; // x becomes 3 * y + 1 a = b = 0; // multiple assignment: a and b both get the value 0
6 Statements 43 6 Statements The statements of C# do not differ very much from those of other programming languages. In addition to assignments and method calls there are various sorts of selections and
More informationLast Class. More on loops break continue A bit on arrays
Last Class More on loops break continue A bit on arrays public class February2{ public static void main(string[] args) { String[] allsubjects = { ReviewArray, Example + arrays, obo errors, 2darrays };
More informationQuestion 0. (1 point) Write the correct ID of the section you normally attend on the cover page of this exam if you have not already done so.
CSE 143 Sp04 Midterm 2 Page 1 of 10 Reference information about some standard Java library classes appears on the last pages of the test. You can tear off these pages for easier reference during the exam
More informationExam 2. CSC 121 MW Class. Lecturer: Howard Rosenthal. April 25, 2016
Your Name: Exam 2. CSC 121 MW Class Lecturer: Howard Rosenthal April 25, 2016 The following questions (or parts of questions) in numbers 1-7 are all worth 3 points each. 1. Answer the following as true
More informationCS Week 5. Jim Williams, PhD
CS 200 - Week 5 Jim Williams, PhD The Study Cycle Check Am I using study methods that are effective? Do I understand the material enough to teach it to others? http://students.lsu.edu/academicsuccess/studying/strategies/tests/studying
More information