CS141 Programming Assignment #10
|
|
- Noel Henderson
- 5 years ago
- Views:
Transcription
1 CS141 Programming Assignment #10 Due Sunday, May 5th. 1) Write a class with the following methods: a) max( int [][] a) Returns the maximum integer in the array. b) min(int [][] a) Returns the minimum integer in the array. c) avergae(int [][] a) Returns the average of integers in the array. d) copy(int [][] a,int [][]b) Copy array a to array b. e) print(int [][] a) Prints the array. 2) Test your class methods you implemented in part 3 on the following array int [][] a = {{10, 5, -6, 0,{11, 8, -2, 7,{4, 6, 2, 1,{9, -5, -3, 50; Make sure to print your answer after each method call. Sol //Student name //Student ID //Assignment# 10 Question #1-2 //DueDate: May 5,2013 //141/51 Computer Programming //This Program containing 5 methods: // 1. Returns the maximum integer in the array // 2. Returns the minimum integer in the array. // 3. Returns the average of integers in the array. // 4. Copy array a to array b. // 5. Prints the array. public class Q1 { /* Method to find the maximum value in an array */ public static int max(int [][] a){ int large = a[0][0]; // stores the initial value to compare with if ( large < a[i][j]) large = a[i][j]; return large; /* Method to find the minimum value in an array */ public static int min(int [][] a){ int small = a[0][0]; // stores the initial value to compare with if ( small > a[i][j]) small = a[i][j]; return small; /* Method to find the average of the values in the array */ public static double average(int [][] a){ int sum = 0; // stores the sum of the values in the array sum += a[i][j]; return sum/(double)(a.length*a.length);
2 /* Method to copy the first array argument into * * the second array argument */ public static void copy(int [][]a, int [][]b){ for(int i = 0; i < a.length; i++){ b[i][j] = a[i][j]; /* Method to print the 2 dimensional array */ public static void print(int [][]a){ for(int i = 0; i < a.length; i++){ System.out.printf("%3d", a[i][j]); public static void main(string[] args) { int [][] a = {{10, 5, -6, 0, {11, 8, -2, 7, {4, 6, 2, 1, {9, -5, -3, 50; System.out.println("The values in the first array are: "); print(a); System.out.println("The maximum value in the array is " + max(a)); System.out.println("The minimum value in the array is " + min(a)); System.out.printf("The average of the values in the array is %.2f\n", average(a)); int [][]b = new int[a.length][a.length]; copy(a, b); System.out.println("The numbers in the second array are: "); print(b); //end main // end class 3) Write a class that reads values of a two-dimensional integer array A[4][4] from the keyboard, and then computes values of integer array B[4], such that B[i] is the smallest value of i-th row of array A. Sol //Student name //Student ID //Assignment# 10 Question #3 //DueDate: May 5,2013 //141/51 Computer Programming //This Program containing 5 methods: import java.util.scanner; public class Q3 {
3 public static void main(string[] args) { int [][]a = new int [4][4]; int []b = new int[4]; readarray(a); findsmall(a,b); printarrays(a, b); /* Method to read the values and store them into the 4x4 matrix */ public static void readarray(int[][]a){ Scanner input = new Scanner(System.in); System.out.println("Enter the values in the 4x4 matrix:"); for(int i = 0; i < a.length; i++) for(int j = 0; j < a[i].length; j++) a[i][j] = input.nextint(); /* Method to find and return the smallest number in an array */ public static int min(int [] a){ int small = a[0]; // Stores an initial value to compare with for (int i = 1; i < a.length; i++) if ( small > a[i]) small = a[i]; return small; /* Method calls method min()to find the smallest value in each * * row and stores it in a second one dimensional array */ public static void findsmall(int [][]a, int []b){ for(int i = 0; i < a.length; i++) b[i] = min(a[i]); /* Method to print the values in the two arrays */ public static void printarrays(int [][]a, int []b){ for(int i = 0; i < a.length; i++){ for(int j = 0; j < a[i].length; j++) System.out.printf("%5d",a[i][j]); System.out.printf(" Smallest is %5d\n", b[i]); 4) Write a class Matrix with the following methods: -Matrix( int row, int col) -Matrix(int [][] m) -print() -fill () -add(matrix a) -sub(matrix a) -mul(matrix a) Sets the matrix array size to row and col Sets the matrix array to the values given by m Prints the matrix array Sets the matrix array values by the user Add the 2 matrices Subtract the two matrices Multiply the two matrices
4 5) Test your class methods you implemented in part 6 on the following Matrices [ ] [ ] Make sure to print your answer after each method call. Sol //Student name //Student ID //Assignment# 10 Question #4-5 //DueDate: May 5,2013 //141/51 Computer Programming //This Program containing 5 methods: //1. Prints the matrix array //2. Sets the matrix array values by the user //3. Add two matrices //4. Subtract two matrices //5. Multiply two matrices import java.util.scanner; class Matrix { private int a[][]; // instance variable to store the matrix /* constructor to set matrix to specific size */ public Matrix(int row, int col) { a = new int[row][col]; /* constructor to set matrix to given values */ public Matrix(int[][] m) { a = new int[m.length][m[0].length]; for (int i = 0; i < m.length; i++) for (int j = 0; j < m[i].length; j++) a[i][j] = m[i][j]; /* method to print the matrix */ public void print() { { System.out.printf("%5d", a[i][j]); /* method to set matrix values by the user */ public void fill() { Scanner input = new Scanner(System.in); System.out.println("Enter the values in your matrix: "); a[i][j] = input.nextint();
5 /* method to add two matrices and return a third matrix containing the result */ public Matrix add(matrix a) { Matrix C = new Matrix(this.a.length, a.a.length); // stores the result if (this.a.length == a.a.length && this.a[0].length == a.a[0].length) { // check if arrays are compatible for (int i = 0; i < this.a.length; i++) for (int j = 0; j < this.a[i].length; j++) C.a[i][j] = this.a[i][j] + a.a[i][j]; else System.out.println("Array rows and columns are incompatible!!" + " Addition could not be performed"); return C; /* method to subtract two matrices and return a third matrix containing the result */ public Matrix sub(matrix a) { Matrix C = new Matrix(this.a.length, a.a.length); // stores the result if (this.a.length == a.a.length && this.a[0].length == a.a[0].length) { // check if array are compatible for (int i = 0; i < this.a.length; i++) for (int j = 0; j < this.a[i].length; j++) C.a[i][j] = this.a[i][j] - a.a[i][j]; else System.out.println("Array rows and columns are incompatible!!" + " Subtraction could not be performed"); return C; /* method to multiply two matrices and return a third matrix containing the result */ public Matrix mul(matrix a) { Matrix C = new Matrix(this.a.length, a.a[0].length); // stores the result if (this.a.length == a.a[0].length) { // check if arrays are compatible for (int i = 0; i < this.a.length; i++) for (int j = 0; j < this.a[i].length; j++) { int sum = 0; for (int k = 0; k < a.a.length; k++) sum += this.a[i][k] * a.a[k][j]; C.a[i][j] = sum; else System.out.println("Array rows and columns are incompatible!!" + " Multiplication could not be performed"); return C; public static void main(string[] args) { int[][] a = { { 3, 4, -4, { 9, 11, 0, { -2, 5, 5 ; Matrix A = new Matrix(a); // first matrix created thru given matrix Matrix B = new Matrix(3, 3);// second matrix created thru specific size B.fill(); System.out.println("The elements in matrix A: "); A.print(); System.out.println("The elements in matrix B:"); B.print();
6 Matrix C = A.add(B); // stores the result of addition System.out.println("A+B= "); C.print(); Matrix D = A.sub(B); // stores the result of subtraction System.out.println("A-B= "); D.print(); Matrix E = A.mul(B); // stores the result of multiplication System.out.println("A*B= "); E.print(); // end main // end class
System.out.printf("Please, enter the value of the base : \n"); base =input.nextint();
CS141 Programming Assignment #6 Due Thursday, Dec 1st. 1) Write a method integerpower(base, exponent) that returns the value of base exponent For example, integerpower(3, 4) calculates 34 (or 3 * 3 * 3
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 informationCS141 Programming Assignment #6
CS141 Programming Assignment #6 Due Sunday, Nov 18th. 1) Write a class with methods to do the following output: a) 5 5 5 5 5 4 4 4 4 3 3 3 2 2 1 b) 1 2 3 4 5 4 3 2 1 1 2 3 4 * 4 3 2 1 1 2 3 * * * 3 2 1
More information1 Short Answer (10 Points Each)
1 Short Answer (10 Points Each) 1. For the following one-dimensional array, show the final array state after each pass of the three sorting algorithms. That is, after each iteration of the outside loop
More informationCS141 Programming Assignment #5
CS141 Programming Assignment #5 Due Wednesday, Nov 16th. 1) Write a class that asks the user for the day number (0 to 6) and prints the day name (Saturday to Friday) using switch statement. Solution 1:
More informationIntroduction. Data in a table or a matrix can be represented using a two-dimensional array. For example:
Chapter 7 MULTIDIMENSIONAL ARRAYS Lecture notes for computer programming 1 Faculty of Engineering and Information Technology Prepared by: Iyad Albayouk ١ Introduction Data in a table or a matrix can be
More informationMidterm Examination (MTA)
M105: Introduction to Programming with Java Midterm Examination (MTA) Spring 2013 / 2014 Question One: [6 marks] Choose the correct answer and write it on the external answer booklet. 1. Compilers and
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 informationLiang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
1 Thus far, you have used one-dimensional arrays to model linear collections of elements. You can use a two-dimensional array to represent a matrix or a table. For example, the following table that describes
More information2. What are the two main components to the CPU and what do each of them do? 3. What is the difference between a compiler and an interpreter?
COSC 117 Final Exam Spring 2011 Name: Part 1: Definitions & Short Answer (3 Points Each) 1. What do CPU and ALU stand for? 2. What are the two main components to the CPU and what do each of them do? 3.
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 informationChapter 8 Multi-Dimensional Arrays
Chapter 8 Multi-Dimensional Arrays 1 1-Dimentional and 2-Dimentional Arrays In the previous chapter we used 1-dimensional arrays to model linear collections of elements. myarray: 6 4 1 9 7 3 2 8 Now think
More information1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002
1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 Name: TA s Name: Tutorial: For Graders Question 1 Question 2 Question 3 Question 4 Question 5 Total Problem 1 (10 Points).
More informationLecture 2. Two-Dimensional Arrays
Lecture 2 Two-Dimensional Arrays 1 Lecture Content 1. 2-D Array Basics 2. Basic Operations on 2-D Array 3. Storing Matrices with Special Properties 4. Applications of 2-D Array 2 1. 2-D Array Basics An
More informationObject Oriented Programming. Java-Lecture 6 - Arrays
Object Oriented Programming Java-Lecture 6 - Arrays Arrays Arrays are data structures consisting of related data items of the same type In Java arrays are objects -> they are considered reference types
More informationM105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014
M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 Question One: Choose the correct answer and write it on the external answer booklet. 1. Java is. a. case
More informationUniversity of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2007 Final Examination Question Max
More informationCS 101 Spring 2007 Midterm 2 Name: ID:
You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure
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 information1 Short Answer (7 Points Each)
1 Short Answer ( Points Each) 1. Write a linear search method for an integer array that takes in an array and target value as parameters and returns the first position of the target in the array. If the
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 informationCS212 Midterm. 1. Read the following code fragments and answer the questions.
CS1 Midterm 1. Read the following code fragments and answer the questions. (a) public void displayabsx(int x) { if (x > 0) { System.out.println(x); return; else { System.out.println(-x); return; System.out.println("Done");
More informationArrays and Lists Review CSC 123 Fall 2018 Howard Rosenthal
Arrays and Lists Review CSC 123 Fall 2018 Howard Rosenthal Lesson Goals Review what an array is Review how to declare arrays Review what reference variables are Review how to pass arrays to methods Review
More informationTutorial about Arrays
Q1: Write Java statements that do the following: Reviewed Tutorial about Arrays a. Declare an array alpha of 15 components of the type int int alpha[] = new int[15]; b. Print the value of the tenth component
More informationExponentiation and Java
Exponentiation and Java Stephen Merrin Abstract We discuss an interesting teaching example for the Java programming language, where the problem is how to handle the operation of exponentiation. Speci cally,
More informationChapter 8 Multidimensional Arrays
Chapter 8 Multidimensional Arrays 8.1 Introduction Thus far, you have used one-dimensional arrays to model linear collections of elements. You can use a two-dimensional array to represent a matrix or a
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 informationCS141 Programming Assignment #8
CS141 Programming Assignment #8 Due Sunday, April 14th. 1- Write a class with methods to do the following output: a) 5 5 5 5 5 4 4 4 4 3 3 3 2 2 1 b) 1 2 3 4 5 4 3 2 1 1 2 3 4 * 4 3 2 1 1 2 3 * * * 3 2
More informationBasic Problem solving Techniques Top Down stepwise refinement If & if else.. While.. Counter controlled and sentinel controlled repetition Usage of
Basic Problem solving Techniques Top Down stepwise refinement If & if.. While.. Counter controlled and sentinel controlled repetition Usage of Assignment increment & decrement operators 1 ECE 161 WEEK
More informationCS110 Programming Language I. Lab 6: Multiple branching Mechanisms
CS110 Programming Language I Lab 6: Multiple branching Mechanisms Computer Science Department Fall 2016 Lab Objectives: In this lab, the student will practice: Using switch as a branching mechanism Lab
More informationArrays. Eng. Mohammed Abdualal
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 9 Arrays
More informationCS111: PROGRAMMING LANGUAGE II
1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables
More informationJump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.
Jump Statements The keyword break and continue are often used in repetition structures to provide additional controls. break: the loop is terminated right after a break statement is executed. continue:
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 information1 Definitions & Short Answer (5 Points Each)
Fall 2013 Final Exam COSC 117 Name: Write all of your responses on these exam pages. If you need more space please use the backs. Make sure that you show all of your work, answers without supporting work
More informationCS Computers & Programming I Review_01 Dr. H. Assadipour
CS 101 - Computers & Programming I Review_01 Dr. H. Assadipour 1. What is the output of this program? public class Q_01 public static void main(string [] args) int x=8; int y=5; double z=12; System.out.println(y/x);
More informationObject Oriented Programming. Java-Lecture 1
Object Oriented Programming Java-Lecture 1 Standard output System.out is known as the standard output object Methods to display text onto the standard output System.out.print prints text onto the screen
More informationwhile (/* array size less than 1*/){ System.out.print("Number of students is invalid. Enter" + "number of students: "); /* read array size again */
import java.util.scanner; public class CourseManager1 { public static void main(string[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter number of students: "); /* read the number
More informationAttendance (2) Performance (3) Oral (5) Total (10) Dated Sign of Subject Teacher
Attendance (2) Performance (3) Oral (5) Total (10) Dated Sign of Subject Teacher Date of Performance:... Actual Date of Completion:... Expected Date of Completion:... ----------------------------------------------------------------------------------------------------------------
More information1 class Lecture5 { 2 3 "Arrays" 4. Zheng-Liang Lu Java Programming 136 / 174
1 class Lecture5 { 2 3 "Arrays" 4 5 } Zheng-Liang Lu Java Programming 136 / 174 Arrays An array stores a large collection of data which is of the same type. 2 // assume the size variable exists above 3
More informationIntroduction to Algorithms and Data Structures
Introduction to Algorithms and Data Structures Lecture 4 Structuring Data: Multidimensional Arrays, Arrays of Objects, and Objects Containing Arrays Grouping Data We don t buy individual eggs; we buy them
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 informationArray. Array Declaration:
Array Arrays are continuous memory locations having fixed size. Where we require storing multiple data elements under single name, there we can use arrays. Arrays are homogenous in nature. It means and
More informationJump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.
Jump Statements The keyword break and continue are often used in repetition structures to provide additional controls. break: the loop is terminated right after a break statement is executed. continue:
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 informationExample: Monte Carlo Simulation 1
Example: Monte Carlo Simulation 1 Write a program which conducts a Monte Carlo simulation to estimate π. 1 See https://en.wikipedia.org/wiki/monte_carlo_method. Zheng-Liang Lu Java Programming 133 / 149
More informationAL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: Text-printing program. CSC 209 JAVA I
AL GHURAIR UNIVERSITY College of Computing CSC 209 JAVA I week 2- Arithmetic and Decision Making: Equality and Relational Operators Objectives: To use arithmetic operators. The precedence of arithmetic
More informationWentworth Institute of Technology. Engineering & Technology WIT COMP1000. Methods
WIT COMP1000 Methods Methods Programs can be logically broken down into a set of tasks Example from horoscope assignment:» Get input (month, day) from user» Determine astrological sign based on inputs
More informationAhmadu Bello University, Zaria Department of Computer Science
Ahmadu Bello University, Zaria Department of Computer Science 216/217 First Semester Test 2 COSC 211 Object Oriented Programming I Date: February 1, 217 Time Allowed: 6 Minutes Instructions: Attempt Question
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 informationAP COMPUTER SCIENCE A
AP COMPUTER SCIENCE A CONTROL FLOW Aug 28 2017 Week 2 http://apcs.cold.rocks 1 More operators! not!= not equals to % remainder! Goes ahead of boolean!= is used just like == % is used just like / http://apcs.cold.rocks
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 informationFundamentals of Programming Data Types & Methods
Fundamentals of Programming Data Types & Methods By Budditha Hettige Overview Summary (Previous Lesson) Java Data types Default values Variables Input data from keyboard Display results Methods Operators
More informationSection 002 Spring CS 170 Exam 1. Name (print): Instructions:
CS 170 Exam 1 Section 002 Spring 2015 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 informationInstructor: Yu Wang 11/16/2012
CS170 SECTION 001 INTRODUCTION TO COMPUTER SCIENCE I, FALL 2012 Midterm Exam II Instructor: Yu Wang 11/16/2012 Name: Emory Alias: INSTRUCTIONS: Keep your eyes on your own paper and do your best to prevent
More informationSupplement: Case Study: Sudoku. For Introduction to Java Programming By Y. Daniel Liang
Supplement: Case Study: Sudoku For Introduction to Java Programming By Y. Daniel Liang This case study can be presented after Chapter 7, Multidimensional Arrays. This book teaches you how to program using
More informationPractice Problems: Instance methods
Practice Problems: Instance methods Submit your java files to D2L. Late work will not be acceptable. a. Write a class Person with a constructor that accepts a name and an age as its argument. These values
More information3/18/2015. Chapter 19 Sorting and Searching SELECTION SORT SORTING AN ARRAY OF INTEGERS SORTING AN ARRAY OF INTEGERS FILE SELECTIONSORTER.
Chapter 19 Sorting and Searching The Plan For Today AP Test Chapter 18 Quiz Corrections Chapter 18 Assignment Due Today Chapter 19 19.1: Selection Sort 19.2: Profiling the Selection Sort Algorithm 19.3:
More informationArrays and Lists CSC 121 Fall 2016 Howard Rosenthal
Arrays and Lists CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand what an array is Understand how to declare arrays Understand what reference variables are Understand how to pass arrays to methods
More informationDeclaring and ini,alizing 2D arrays
Declaring and ini,alizing 2D arrays 4 2D Arrays (Savitch, Chapter 7.5) TOPICS Multidimensional Arrays 2D Array Allocation 2D Array Initialization TicTacToe Game // se2ng up a 2D array final int M=3, N=4;
More informationa) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable.
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2008 January Exam Question Max Internal
More informationProgramming with Java
Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules
More informationCSE Fall 2015 Section 002 Exam 2, Time: 80 mins
CSE 1310 - Fall 2015 Section 002 Exam 2, Time: 80 mins Name:. Student ID:. Total exam points: 100. Question Points Out of 1 20 2 20 3 20 4 20 5 20 6 20 Total 100 SOLVE 5 OUT 6 PROBLEMS. You must specify
More informationJAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop
Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly
More informationCSEN 202: Introduction to Computer Programming Spring term Final Exam
Page 0 German University in Cairo May 28, 2016 Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Wael Aboul Saadat CSEN 202: Introduction to Computer Programming Spring term 2015-2016 Final
More informationLoops. Eng. Mohammed Abdualal. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 6 Loops
More informationLab Assignment Three
Lab Assignment Three C212/A592 Fall Semester 2010 Due in OnCourse by Friday, September 17, 11:55pm (Dropbox will stay open until Saturday, September 18, 11:55pm) Abstract Read and solve the problems below.
More informationCSCI 1103: File I/O, Scanner, PrintWriter
CSCI 1103: File I/O, Scanner, PrintWriter Chris Kauffman Last Updated: Mon Dec 4 10:03:11 CST 2017 1 Logistics Reading from Eck Ch 2.1 on Input, File I/O Ch 11.1-2 on File I/O Goals Scanner for input Input
More informationLearning objec-ves. Declaring and ini-alizing 2D arrays. Prin-ng 2D arrays. Using 2D arrays Decomposi-on of a solu-on into objects and methods
Learning objec-ves 2D Arrays (Savitch, Chapter 7.5) TOPICS Using 2D arrays Decomposi-on of a solu-on into objects and methods Multidimensional Arrays 2D Array Allocation 2D Array Initialization TicTacToe
More informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #07: September 21, 2015 1/30 We explained last time that an array is an ordered list of values. Each value is stored at a specific, numbered position in
More informationArrays and Lists CSC 121 Fall 2015 Howard Rosenthal
Arrays and Lists CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand what an array is Understand how to declare arrays Understand what reference variables are Understand how to pass arrays to methods
More informationDefining Classes. The basic syntax for defining a class in Java is: class <class-name> [<data-declarations>] [<class-constructors>] [<methods>]
Defining Classes As well as using predefined library classes in Java programs, it is usual to define new classes as well. The library classes model commonly occurring situations, the new classes are used
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 informationLAB 13: ARRAYS (ONE DIMINSION)
Statement Purpose: The purpose of this Lab. is to practically familiarize student with the concept of array and related operations performed on array. Activity Outcomes: As a second Lab on Chapter 7, this
More informationArrays and Lists CSC 121 Fall 2014 Howard Rosenthal
Arrays and Lists CSC 121 Fall 2014 Howard Rosenthal Lesson Goals Understand what an array is Understand how to declare arrays Understand what reference variables are Understand how to pass arrays to methods
More informationAL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I
AL GHURAIR UNIVERSITY College of Computing CSC 209 JAVA I week 3- Control Statements: Part I Objectives: To use the if and if...else selection statements to choose among alternative actions. To use the
More informationITERATION WEEK 4: EXMAPLES IN CLASS
Monday Section 2 import java.util.scanner; public class W4MSection2 { ITERATION WEEK 4: EXMAPLES IN CLASS public static void main(string[] args) { Scanner input1 = new Scanner (System.in); int CircleCenterX
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes
More informationQuestion: Total Points: Score:
CS 170 Exam 1 Section 001 Fall 2014 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 informationChapter 01 Arrays Prepared By: Dr. Murad Magableh 2013
Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013 One Dimensional Q1: Write a program that declares two arrays of integers and fills them from the user. Then exchanges their values and display the
More informationCOSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand
COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us or http://www.class-notes.info or http://www.lecture-notes.tripod.com
More informationUNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 10 INTRODUCTION TO ARRAYS
UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 10 INTRODUCTION TO ARRAYS EXERCISE 10.1 1. An array can contain many items and still be treated as one thing. Thus, instead of having many variables for
More informationFall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.
Grading Page 1 / 4 Page3 / 20 Page 4 / 13 Page 5 / 10 Page 6 / 26 Page 7 / 17 Page 8 / 10 Total / 100 1. (4 points) What is your course section? CS 101 CS 101E Pledged Page 1 of 8 Pledged The following
More information1 class Lecture5 { 2 3 "Methods" / References 8 [1] Ch. 5 in YDL 9 [1] Ch. 20 in YDL 0 / Zheng-Liang Lu Java Programming 176 / 199
1 class Lecture5 { 2 3 "Methods" 4 5 } 6 7 / References 8 [1] Ch. 5 in YDL 9 [1] Ch. 20 in YDL 0 / Zheng-Liang Lu Java Programming 176 / 199 Methods 2 Methods can be used to define reusable code, and organize
More informationMultidimensional Arrays. CSE 114, Computer Science 1 Stony Brook University
Multidimensional Arrays CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Multidimensional Arrays How do we represent matrices or tables? A two-dimensional array
More informationWelcome1.java // Fig. 2.1: Welcome1.java // Text-printing program.
1 Welcome1.java // Fig. 2.1: Welcome1.java // Text-printing program. public class Welcome1 // main method begins execution of Java application System.out.println( "Welcome to Java Programming!" ); } //
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 information2.8. Decision Making: Equality and Relational Operators
Page 1 of 6 [Page 56] 2.8. Decision Making: Equality and Relational Operators A condition is an expression that can be either true or false. This section introduces a simple version of Java's if statement
More informationCIS November 14, 2017
CIS 1068 November 14, 2017 Administrative Stuff Netflix Challenge New assignment posted soon Lab grades Last Time. Building Our Own Classes Why Abstraction More on the new operator Fields Class vs the
More informationCIS 1068 Netflix Challenge New assignment posted soon Lab grades November 14, 2017
Administrative Stuff CIS 1068 Netflix Challenge New assignment posted soon Lab grades November 14, 2017 Last Time. Building Our Own Classes Why Abstraction More on the new operator Fields Class vs the
More informationCS18000: Programming I
CS18000: Programming I Introduction to Concurrency January 20, 2010 Prof. Chris Clifton Today We Learn Functions as Abstractions A First View of Concurrency Threads 1/21/2010 CS18000 2 Prof. Chris Clifton
More informationExercise 4: Loops, Arrays and Files
Exercise 4: Loops, Arrays and Files worth 24% of the final mark November 4, 2004 Instructions Submit your programs in a floppy disk. Deliver the disk to Michele Zito at the 12noon lecture on Tuesday November
More informationCh. 6. User-Defined Methods
Ch. 6 User-Defined Methods Func5onal Abstrac5on Func5onal regarding func5ons/methods Abstrac5on solving a problem in a crea5ve way Stepwise refinement breaking down large problems into small problems The
More informationArrays, Vectors, Matrices
Arrays, Vectors, Matrices Goal: o Scientific Eng. o Numerical computations o Array are very efficient way of organizing data since accessing array elements requires O(1). Characteristics of an array: o
More informationLab #10 Multi-dimensional Arrays
Multi-dimensional Arrays Sheet s Owner Student ID Name Signature Group partner 1. Two-Dimensional Arrays Arrays that we have seen and used so far are one dimensional arrays, where each element is indexed
More informationComputer Science & Engineering 150A Problem Solving Using Computers
Computer Science & Engineering 150A Problem Solving Using Computers Lecture 06 - Stephen Scott Adapted from Christopher M. Bourke 1 / 30 Fall 2009 Chapter 8 8.1 Declaring and 8.2 Array Subscripts 8.3 Using
More informationWhat are Exceptions?
Exception Handling What are Exceptions? The traditional approach Exception handing in Java Standard exceptions in Java Multiple catch handlers Catching multiple exceptions finally block Checked vs unchecked
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 informationAhmadu Bello University Department of Mathematics First Semester Examinations June 2014 COSC211: Introduction to Object Oriented Programming I
Ahmadu Bello University Department of Mathematics First Semester Examinations June 2014 COSC211: Introduction to Object Oriented Programming I Attempt Four questions Time: 120 mins 1. Examine the following
More informationCloning Arrays. In practice, one might duplicate an array for some reason. One could attempt to use the assignment statement (=), for example,
Cloning Arrays In practice, one might duplicate an array for some reason. One could attempt to use the assignment statement (=), for example, 1... 2 T[] A = {...}; // assume A is an array 3 T[] B = A;
More information