What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.

Slides:



Advertisements
Similar presentations
1 CS 105 Lecture 11 Arrays Version of Wed, Apr 6, 2011, 6:20 pm.
Advertisements

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 14, 2005.
Programming with Collections Collections in Java Using Arrays Week 9.
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
COMP 14 Introduction to Programming Miguel A. Otaduy June 1, 2004.
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
CS1101: Programming Methodology Recitation 3 – Control Structures.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
The for Loop Syntax: for ( expression1 ; condition ; expression2 ) statement ; for ( expression1 ; condition ; expression2 ) { statement ; } Same as: expression1.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
1 One Dimensional Arrays Chapter 11 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores :
CSCI 1226 FALL 2015 MIDTERM #1 REVIEWS.  Types of computers:  Personal computers  Embedded systems  Servers  Hardware:  I/O devices: mice, keyboards,
Jeopardy $100 VariablesErrorsLoops Classes and Objects Program Structure $200 $300 $400 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300.
Exam 2 EXAM 2 Thursday!!! 25% of Final Grade Know: loops, switch/case Files Input failure (e.g. scan.hasNextInt())
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS 1 Copyright: 2015 Illinois Institute of Technology_ George Koutsogiannakis.
Chapter 5 – Part 3 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved2/19 Outline The if Statement and Conditions Other Conditional.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Quiz 1 Exam 1 Next Monday. Nested if Statements if (myGrade >= 80) if (myGrade >= 90) System.out.println(“You have an A!” ); else System.out.println(“You.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Lecture 4 CS140 Dick Steflik. Reading Keyboard Input Import java.util.Scanner – A simple text scanner which can parse primitive types and strings using.
ARRAYS.
Pointers and Classes.
Some Assignments  Write a program which prints the following information about at least 5 persons: NAME MAIL-ID EMPLOYEE-CODE PHONE Eg. Umesh
CSC 221: Computer Programming I Spring 2010
Yanal Alahmad Java Workshop Yanal Alahmad
Objectives Identify the built-in data types in C++
Chapter 7 Part 1 Edited by JJ Shepherd
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Chapter 5: Control Structures II
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
CS 177 Week 15 Recitation Slides
Arrays, For loop While loop Do while loop
Selection (if-then-else)
C Programming APP3o.
Building Java Programs
Java Array ISYS 350.
int [] scores = new int [10];
Know for Quiz Everything through Last Week and Lab 7
Exam 2 EXAM 2 Thursday!!! 25% of Final Grade
Announcements Exam 1 Thursday 50 minutes 10 % of Total Grade
File Review Declare the File Stream Object Name
Arrays Syntax: type variableName[size];
Announcements Exam 1 Thursday Everything through Lab 5 50 minutes
CS 200 Loops Jim Williams, PhD.
Announcements Exam 1 Grades Posted on Blackboard.
Arrays of Objects // The following does NOT create memory for
Let’s all Repeat Together
Building Java Programs
Structure.
Lecture 1 Review of 1301/1321 CSE /26/2018.
OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS
INC 161 , CPE 100 Computer Programming
Arrays in Java.
Structures In C Programming By Rajanikanth B.
Copyright © 2013 Elsevier Inc. All rights reserved.
Announcements Quiz 5: grades and solution posted
Building Java Programs
Repetition Statements
CS150 Introduction to Computer Science 1
Building Java Programs
Consider Write a program that prompts a user to enter the number of students and then, their names and grades. The program will then outputs the average.
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Announcements Exam 2 Lecture Grades Posted on blackboard
CS 1054 Final Exam Coverage Final exam will cover Chapters 1-8, 10-11
Week 7 - Monday CS 121.
Presentation transcript:

What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.

Program for Previous String empName1, empName2, empName3,… String empLocation1, empLocation2, … System.out.print( “Enter employee name 1:”); empName1 = scan.next(); System.out.print(“Enter employee name 2:”); empName2 = scan.next(); … //Can we use a loop?

Arrays Syntax: type variableName[] = new type [size]; Memory Is Set Aside for size Items of type Each Variable Location in Array Is Accessed by Offsetting into the Array with an Integer Expression Legitimate Offsets Are 0 to size-1

Array Example char [] lastname = new char[100]; lastname[0] = ‘H’; lastname[1] = ‘a’; lastname[2] = ‘\0’; System.out.println( lastname[0]);

Array Example int [] values = new int[15]; int i = 0; values[i] = 150; System.out.println( values[0]); values[3] = values[0] + 6;

Array Example final int ARRAY_SIZE = 100; int offset; int [] numArray = new int [ARRAY_SIZE]; for(offset = 0; offset < ARRAY_SIZE; offset++) { numArray[offset] = 0; } for(offset = 0; offset < numArray.length; offset++) numArray[offset] = offset;

Arrays of Objects // The following does NOT create memory for // objects, it only makes a blueprint array Employee [] employees = new Employee [MAXEMP]; // Must create memory and call constructor for // each single member of aray of objects for (i = 0; i < MAXEMP; i++) employees[i] = new Employee();

Array Example final int ARRAY_SIZE = 10; int offset, sum = 0, average; int [] numArray = new int[ARRAY_SIZE]; for(offset = 0; offset < ARRAY_SIZE; offset++) { System.out.print( “Enter Score ” + offset + “ : “); numArray[offset] = scan.nextInt(); } sum = sum + numArray[offset]; average = sum / ARRAY_SIZE;

Project Posted on blackboard under Tasks Hand in to your TA (NOT me!) .java for Client Program (source code), .java for Class (source code), .txt (Data file runwaycs115.txt), .doc (Analysis) Pseudocode!!!!! Design before Coding!!!! Start *TODAY*!!!!

Project Do’s Start this week (read project at least) Write Pseudocode/Design FIRST Start Small, Test Often, Add Little by Little Backup Versions Often Review All cs115 Concepts – Do Well on Final Exam

Don’t’s No Working Together Write your own Code Checked by Supercomputer May be Called in to Discuss Program Last Term – 10 Investigated, 7 0s, 1 probation Eleven terms (94 investigated, 64 received 0s)