Assignment Array Sorter NSF WorkshopPam Lawhead. Overview The purpose of this assignment is to give the student experience using Java arrays, light sensors.

Slides:



Advertisements
Similar presentations
C Language.
Advertisements

Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
Chapter 3: Engage! Android User Input, Variables, and Operations
2/18/2008ITK 1681 Feb. 20, Wed. 8:00 – 9:30 pm STV Closed book, notes, and no computer is allowed. 2.Everyone is allowed to bring a self- prepared.
Chapter 10 Introduction to Arrays
Introduction to Computers and Programming Midterm Review Sana Odeh.
Topic 9 – Introduction To Arrays. CISC105 – Topic 9 Introduction to Data Structures Thus far, we have seen “simple” data types. These refers to a single.
Getting Ready to go with LeJos and an IDE NSF Workshop November 19-21, 2004 The University of Mississippi Pam Lawhead.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
The Turtle Laboratory Sequence Myles McNally LMICSE Workshop November , 2004 University of Mississippi.
Introduction to Java, OO and IDEs ICW Lecture 2 Errol Thompson Room 134.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 9 Pointers and Dynamic Arrays.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
ASP.NET Programming with C# and SQL Server First Edition
Arrays. Objectives Learn about arrays Explore how to declare and manipulate data into arrays Learn about “array index out of bounds” Become familiar with.
Chapter 9 Introduction to Arrays
Introduction to Programming. To gain a sound knowledge of programming principles To gain a sound knowledge of object- orientation To be able to critically.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
ECE122 L17: Method Development and Testing April 5, 2007 ECE 122 Engineering Problem Solving with Java Lecture 17 Method Development and Testing.
Testing Test Plans and Regression Testing. Programs need testing! Writing a program involves more than knowing the syntax and semantics of a language.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Patterns, frameworks & Lejos
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
IE 212: Computational Methods for Industrial Engineering
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Java: Chapter 1 Computer Systems Computer Programming II.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
A First Book of ANSI C Fourth Edition
EGR 2261 Unit 8 One-dimensional Arrays  Read Malik, pages in Chapter 8.  Homework #8 and Lab #8 due next week.  Quiz next week.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
BUILDING JAVA PROGRAMS CHAPTER 7 Arrays. Exam #2: Chapters 1-6 Thursday Dec. 4th.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Chapter 4 Grouping Objects. Flexible Sized Collections  When writing a program, we often need to be able to group objects into collections  It is typical.
Files Tutor: You will need ….
Arithmetic, Class Variables and Class Methods Week 11
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
Separate Compilation Bryce Boe 2013/10/09 CS24, Fall 2013.
Structuring Data: Arrays ANSI-C. Representing multiple homogenous data Problem: Input: Desired output:
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Arrays Chapter 7. MIS Object Oriented Systems Arrays UTD, SOM 2 Objectives Nature and purpose of an array Using arrays in Java programs Methods.
Designing Lego Labs Using Lejos and Mindstorms Adapted from Lynn Stein “Radically ReThinking CS1” NSF Workshop.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
Chapter 9 Introduction to Arrays Fundamentals of Java.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Arrays Chapter 7.
Introducing Instructions
Getting Ready to go with LeJos and an IDE
An Introduction to VEX IQ Programming with Modkit
PRG 421 Week 1 Individual: Week One Analyze Assignment--
Building Java Programs Chapter 2
Topics Introduction to File Input and Output
CS005 Introduction to Programming
An Introduction to VEX IQ Programming with Modkit
Implementing Classes Chapter 3.
Programming in JavaScript
Programming Fundamentals (750113) Ch1. Problem Solving
Programming in JavaScript
Programming Fundamentals (750113) Ch1. Problem Solving
Data Structures & Algorithms
Topics Introduction to File Input and Output
LEGO Mindstorms Robot and Java
Presentation transcript:

Assignment Array Sorter NSF WorkshopPam Lawhead

Overview The purpose of this assignment is to give the student experience using Java arrays, light sensors and arrays to sort the sensor reading stored in an array. The text used for this class (Lambert and Osborne) provides code for sorting a simple on dimensional array. This code may be used in this assignment. The only sensor required is a light sensor. You need to read Chapter 7 in your textbook very carefully to understand classes. Next, you need to answer the following questions BEFORE you come to lab.

Background The array data structure is provided by the Java programming language to handle those situations where many similar items need to be read, manipulated, stored, written or dealt with by the computer in some way.. The actual assignment has an extensive background section

Problem Statement You have been chosen as the field tester for the Our Colors Don’t Fade in the Sun Paint company. The sun shines unrelentingly here in summertime Mississippi and you have decided that it is entirely too hot for you to go out each day and take the readings from each color sample to determine if there has been any change. The goal is to keep the colors stored in the company’s primary computer from lightest to darkest. To do this you must write a program that allows a robot to travel across a field of sample paint colors, take a reading of each using the light sensor, and then store that value in an array of colors. Once the colors have been collected, you need the robot to return those values to the main computer where they will be stored and sorted for future use. Your company is a start-up company so it is not making many different colors of paint at this time. In this case, “summer paint sun test” there are only 5 colors that are being tested. As profits increase, the company will add additional colors to it’s a palette but, for now, 5 will do.

Lab Preparation 1. What is the Java syntax for declaring an array? 2. What new leJos classes will you need to complete this assignment? 3. What are constructors used for? How are they defined? 4. What is the simplest way that you can sort a list of numbers? 5. What are the classes that have you already written that can be reused here? 6. Will you need two arrays to sort the numbers? How will you handle that?

Laboratory Robot needed: RCX brick, two motors, 4 (or 2) wheels and one light sensor LeJos classes and methods needed: Motor: setPower(int aPower), forward(), backward(), stop(),flt() Sensor: activate(), passvate(), int readPercentage()(for light sensor ) LCD: showNumber(int value), RCXComm

Solution Strategy (Note: You might need to write a little test program to determine the light sensor percentage for the different colors.) You need to be sure that the paint colors are distinct enough that the different colors can be recognized by the sensor. You might need to put a black line between the colors. You need to first identify the different parts of your program - objects, attributes and methods. Decide what variables that you will need. What methods will be required to access these variables? Using the description of a class template found in your book on p. 160 define each of the four parts of your robot class template.

Solution Strategy (continued) Write each of the methods that you have identified in step one. How will you get your robot to return values to the PC? What class will you use? What methods in that class will be required? What are the arguments required? Hint: You might have a problem with the robot running too fast to get accurate readings of each of the colors, what are some solutions to that problem?

Testing 1. What is the first thing that you need to test? 2. What should the output from this program look like? 3. What is the input? 4. What would be an example of the program not working? 5. What would you do to fix the problem identified in question 4? 6. What are the expected inputs and outputs of each module? 7. What would it mean for a value to be out of bounds for each module? 8. What are two different ways that an array could be out of bounds?