Free Essay

Arrays

In:

Submitted By ToshidaPro
Words 359
Pages 2
-------------------------------------------------
John Lowell Santos Assignment in Copro2 BSCS1-2A

Code: DrawStringDemo.java

Explanation: As we see, It draws the String “STI Incorporated” as what have assign in the code. The method used was the DrawString() which “Draws the String”.
Code: DrawArcDemo.java

Explanation: In this code a method DrawArc() and FillArc() was used. It has 6 parameters that assign to a point to which the object was created and formed like that. The output became dark because of FillArc() which it fills the space inside the arc and also it is the same parameters as the arc have.

Code: JDemoPaint.java

Explanation: A button was assign to repaint() method. When we click the “Press here” button, It updates the window. There is also a counting that counts how many times we repaint the applet.
Code: RoundRectDemo

Explanation: As what we have seen, this illustrates how we draw a rectangle into circle. Its uses 6 parameters as the x and y location, the height and the width, and the point how it bends. In this output the increment of the points was 20, until the last number was 80 in which we draw a circle. TADAAA

Code: SetFontDemo

Explanation: This output is same as the Code DrawStingDemo.java but sets the font to Verdana, Bold, and size 26.
Code: DrawPolyDemo

Explanation: As what we seen above, we draw a Polygon that has 5 sides. We use an array that has 6 elements that assigns the point and location of our polygon. Following codes may explain: int xPoints[] = {5, 25, 50, 30, 15, 5}; int yPoints[] = {10, 35, 20, 65, 40, 10};

Code: RectangleDemo

Explanation: The method used for this output was fillRect() and clearRect(). As what you have seen in the output. The fillRect() is the Rectangle inside the Rectangle and the clearRect() was the Rectangle outside the Rectangle inside the Rectangle or what we called the Rectangle.
Code: SetColorDemo

Explanation: This is same as the Code SetFontDemo.java but in this case, the Color of the font was changed to Blue but the I think I don’t know why the background that had been set yellow wouldn’t appear.

Similar Documents

Free Essay

Arrays

...CHAPTER 5 – ARRAYS CASE STUDY SCENARIO Sorting Data A dozen umbrellas lie on the ground just inside the classroom door when Dr. Taylor begins his lecture. “A cold, rainy day like today makes me want to stay in and order pizza for delivery rather than go out myself.” Handing a phone book to a student in the front row, Dr. Taylor says “Gail, please look up the phone number for Domino’s Pizza on Main Street, and if you don’t mind, I will time how long it takes you to find the number.” Gail flips through a few pages while Dr. Taylor looks at his watch. “Here it is . . . 555-8275,” she says. “Seven seconds. Thank you Gail.” Dr. Taylor presses some keys on his cell phone while continuing his conversation. “Now please look up the name of the person with the phone number 555-5982, and again I will time you.” Dr. Taylor’s focus returns to his watch even as he speaks into the phone. Gail slowly flips a couple of pages, then stops just about the same time Dr. Taylor ends his call. “I assure you the number is in there, Gail. We will wait while you look it up.” “You will probably wait a long time,” she says, “because there is no fast way to find a number.” “Why not? It’s the same data.” “But the phone book is sorted by names, so finding a name is easy. Finding a number is very difficult because a phone book is not sorted by numbers.” Dr. Taylor takes the phone book from Gail. “Exactly! The sorting process does not change the data, but it organizes the data in a context...

Words: 5653 - Pages: 23

Free Essay

Java Array

...Java provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables. This tutorial introduces how to declare array variables, create arrays, and process arrays using indexed variables. Declaring Array Variables: To use an array in a program, you must declare a variable to reference the array, and you must specify the type of array the variable can reference. Here is the syntax for declaring an array variable: ------------------------------------------------- dataType[] arrayRefVar; // preferred way. ------------------------------------------------- ------------------------------------------------- or ------------------------------------------------- ------------------------------------------------- dataType arrayRefVar[]; // works but not preferred way. Note: The style dataType[] arrayRefVar is preferred. The style dataType arrayRefVar[] comes from the C/C++ language and was adopted in Java to accommodate C/C++ programmers. Example: The following code snippets are...

Words: 1665 - Pages: 7

Free Essay

Tutorial on Pointers and Arrays in C

...A Tutorial on Pointers and Arrays in C A TUTORIAL ON POINTERS AND ARRAYS IN C by Ted Jensen Version 1.1 (HTML version) July 1998 This material is hereby placed in the public domain Available in various formats via http://www.netcom.com/~tjensen/ptr/cpoint.htm TABLE OF CONTENTS Preface Introduction Chapter 1: What is a Pointer? Chapter 2: Pointer Types and Arrays. Chapter 3: Pointers and Strings Chapter 4: More on Strings Chapter 5: Pointers and Structures Chapter 6: More on Strings and Arrays of Strings Chapter 7: More on Multi-Dimensional Arrays Chapter 8: Pointers to Arrays Chapter 9: Pointers and Dynamic Allocation of Memory Chapter 10: Pointers to Functions file:///E|/My%20eBooks/_ESSENTIALS_/A%20Tutorial%...orial%20on%20Pointers%20and%20Arrays%20in%20C.htm (1 of 2)3/18/2007 12:09:49 AM A Tutorial on Pointers and Arrays in C Epilog file:///E|/My%20eBooks/_ESSENTIALS_/A%20Tutorial%...orial%20on%20Pointers%20and%20Arrays%20in%20C.htm (2 of 2)3/18/2007 12:09:49 AM Preface PREFACE This document is intended to introduce pointers to beginning programmers in the C programming language. Over several years of reading and contributing to various conferences on C including those on the FidoNet and UseNet, I have noted a large number of newcomers to C appear to have a difficult time in grasping the fundamentals of pointers. I therefore undertook the task of trying to explain them in plain language with lots of examples. The first version of this document was...

Words: 9878 - Pages: 40

Free Essay

Video Graphics Array

...Definition of:VGA(1) (Video Graphics Array) For compatibility with earlier monitors and data projectors, laptop computers often include a VGA port, which was widely used on PCs (see definition #2 below). VGA on a Laptop A VGA socket (middle) is commonly found on Windows-based laptops and entry-level PCs. Macs use only DisplayPort (left) and Mini DisplayPort sockets (see DisplayPort). (2) (Video Graphics Array) An analog interface between a computer and monitor that was widely used prior to the DVI standard. Older CRTs used VGA, and flat LCD panels typically have both analog VGA and digital DVI. However, newer PCs may have only DVI or DisplayPort outputs. See flat panel display, DVI and DisplayPort. VGA Is Base Level VGA officially refers to only 640x480 pixels with 16 or 256 colors. This base resolution is used to boot the PC and also troubleshoot the computer in Safe Mode with the display driver disabled (in case the driver is the cause of the problem). VGA History VGA was introduced on IBM's PS/2 line in 1987 and quickly replaced the earlier digital CGA and EGA interfaces, which had lower resolution and fewer colors. In a short time, non-IBM vendors boosted resolution and colors, calling them "Super VGA." IBM later introduced XGA with a 1024x768 resolution, and over the years, numerous resolutions were added that were fractions or multiples of the total number of pixels in VGA and XGA resolutions. See screen resolution and XGA. The VGA Port (Socket) Using D-sub...

Words: 295 - Pages: 2

Free Essay

Analysis of Physical Parameters Influencing Beam Pattern of Uniform Linear Array of Antennas

...ANALYSIS OF THE PHYSICAL PARAMETERS INFLUENCING BEAM PATTERN OF A UNIFORM LINEAR ARRAY OF ANTENNAS Final Year Project Report Presented by SAJID UR REHMAN CIIT/SP08-BET-090/ISB USMAN ULLAH ASIF CIIT/SP08-BET-121/ISB In Partial Fulfillment Of the Requirement for the Degree of Bachelor of Science in Electrical (Telecommunication) Engineering DEPARTMENT OF ELECTRICAL ENGINEERING COMSATS INSTITUTE OF INFORMATION Technology, ISLAMABAD JAN 2012 Declaration We, hereby declare that this project neither as a whole nor as a part there of has been copied out from any source. It is further declared that we have developed this project and the accompanied report entirely on the basis of our personal efforts made under the sincere guidance of our supervisor. No portion of the work presented in this report has been submitted in the support of any other degree or qualification of this or any other University or Institute of learning, if found we shall stand responsible. Signature:______________ Sajid Ur Rehman Signature:______________ UsmanUllah Asif COMSATS INSTITUTE OF INFORMATION Technology, ISLAMABAD JAN 2012 ANALYSIS OF THE PHYSICAL PARAMETERS INFLUENCING BEAM PATTERN OF A UNIFORM LINEAR ARRAY OF ANTENNAS An Undergraduate Final Year Project Report submitted to the Department of ELECTRICAL ENGINEERING As a Partial Fulfillment...

Words: 6048 - Pages: 25

Free Essay

Array

...Nouns | | Verbs | | | | | | Program | Hours | Design | | Arrays | Data | Uses | | People | | Hold | | Integers | | Worked | | Subscripts | | Relate | | Numbers | | Stored | | Pay | | Ask | | wages | | Entered | | hours | | display | | Word Analysis Variable Chart Input | Interim | Output | hours | [index] | wages | empId | | | payRate | | | | | | | | | | | | Major Task List 1. Input hours, employee id numbers, and payrates 2. Create arrays 3. Calculate wages to employee 4. Display results Structure Chart Main Main Psuedo Code PROGRAM Employees AUTHOR Stuart Marlar COURSE COP1000 FUNCTION main (void) RETURNING int BEGIN main Declare Integer Index Declare Integer Array empId[7] = (56588, 45201, 78951, 87775, 84512, 13028, 75804) Declare Double Array hours[7] = (0) Declare Double Array payRate[7] = (0) Declare Double Array wages[7] = (0) FOR index = 0 TO 7 - 1 STEP 1 DO OUTPUT "Employee ID" empId[index] REPEAT OUTPUT "Enter hours" INPUT hours[index] IF hours[index] OUTPUT"Hours cannot be negative" END-IF WHILE hour[index] < 0 ...

Words: 422 - Pages: 2

Premium Essay

Array

...Associate Program Material Simple Array Process Input a list of employee names and salaries, and determine the mean (average) salary as well as the number of salaries above and below the mean. Process                    Display Program Title                    Give instructions on the program                    Open file for interactive input (write)                    Prompt for Names and Salaries                    Check for negative numbers                    Check for sentinel value Loop until sentinel value is entered Get running total for Sum Get running total for Count Write input values to file Close file after input Determine if count is equal or greater than 1 Calculate average salary Display average salary Prompt for input Response Determine if user wants to continue Open file for batch processing (read) Loop for processing file Read salary field Gather running total for both count variables When the loop reaches EOF close file Display count variables as output                              Input                    Input Name (Name: String)                    Input Salary (Salary: Real)           Output                    Display Average salary                    Display Count_2 above average salary                    Display Count_3 below average salary ...

Words: 471 - Pages: 2

Free Essay

Array

...and their state of residence. The program will display the average age of all family members input, and also display the names of any family members that live in Texas. We will create three separate arrays; one for the names of the family members, another for their ages, and the third will be for their state of residence. We'll first ask the user to enter the number of family members he has (we will limit this to a max of 25); this will allow us to determine how large of arrays we will need to create to store the data. We'll call this variable Size. After inputting all names, ages, and states of residence the data will all be stored within the arrays. The program will identify those family members who reside in Texas, and also display their names on the screen. This will be done by creating a loop that will review all the entries from the names and residencies arrays, compare the state to the string "Texas," and print that corresponding name. The average age will be calculated by also looping through the values in the age array, calculating the collective sum, then (as stated earlier) dividing by Size. Necessary Calculations The variable AvgAge (declared as Float) will be used in order to calculate the average age. A loop will go through each value of the Ages array, keep a running total sum, then divide that total by the variable Size to get the average age. //NOTE: I use Float instead of Integer because there is a possibility of losing a trailing decimal if //numerical...

Words: 617 - Pages: 3

Free Essay

Matlab & Ss

...Lab 1: Introduction to MATLAB Warm-up MATLAB is a high-level programming language that has been used extensively to solve complex engineering problems. The language itself bears some similarities with ANSI C and FORTRAN. MATLAB works with three types of windows on your computer screen. These are the Command window, the Figure window and the Editor window. The Figure window only pops up whenever you plot something. The Editor window is used for writing and editing MATLAB programs (called M-files) and can be invoked in Windows from the pull-down menu after selecting File | New | M-file. In UNIX, the Editor window pops up when you type in the command window: edit filename (‘filename’ is the name of the file you want to create). The command window is the main window in which you communicate with the MATLAB interpreter. The MATLAB interpreter displays a command >> indicating that it is ready to accept commands from you. • View the MATLAB introduction by typing >> intro at the MATLAB prompt. This short introduction will demonstrate some basic MATLAB commands. • Explore MATLAB’s help capability by trying the following: >> help >> help plot >> help ops >> help arith • Type demo and explore some of the demos of MATLAB commands. • You can use the command window as a calculator, or you can use it to call other MATLAB programs (M-files). Say you want to evaluate the expression [pic], where a=1.2, b=2.3, c=4.5 and d=4....

Words: 2151 - Pages: 9

Free Essay

Vba Intro

...questions about VBA. † Finance Dept, Kellogg School, Northwestern University, 2001 Sheridan Rd., Evanston, IL 60208, tel: 847-491-8344, fax: 847-491-5719, E-mail: r-mcdonald@northwestern.edu. CONTENTS 2 5 Storing and Retrieving Variables in a Worksheet 5.1 Using a named range to read and write numbers from spreadsheet . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Reading and Writing to Cells Which are not Named. . . 5.3 Using the “Cells” Function to Read and Write to Cells. 10 the . . . . . . . . . 11 12 13 6 Using Excel Functions 13 6.1 Using VBA to compute the Black-Scholes formula . . . . . . 13 6.2 The Object Browser . . . . . . . . . . . . . . . . . . . . . . . 15 7 Checking for Conditions 16 8 Arrays 17 8.1 Defining Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 18 9 Iterating 19 9.1 A simple for loop . . . . . . . . . . . . . . . . . . . . . . . . . 20 9.2 Creating a binomial tree . . . . . . . . . . . . . . . . . . . . . 20 9.3 Other...

Words: 10883 - Pages: 44

Free Essay

Ecet 370 Hw1

...======================================== DeVry College of New York ECET 370 HW #1: Dynamic 2D-array ------------------------------------------------- Objective: Write a program to calculate students’ average test scores and their grades. You may assume the following file input data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three arrays: a one-dimensional array to store the students’ names, a (parallel) two-dimensional array to store the test scores, and a parallel one dimensional array to store grades. Your program must contain at least the following functions: a function to read and store data into two arrays, a function to calculate the average test score and grade, and a function to output the results. Have your program also output the class average. Tools required: PC & Visual studio software Code: #include <iostream> #include <fstream> #include <sstream> #include <string> using namespace std; bool readStudentData(ifstream &inFile, string &name, int &score1, int &score2, int &score3, int &score4, int &score5) { string line; if (getline(inFile, line)) { string word; istringstream iss(line, istringstream::in); int count = 0; try { while (iss >> word) { //cout...

Words: 673 - Pages: 3

Premium Essay

Logic and Design

...Programming Logic and Design, 6th Edition Chapter 6 Exercises 1. a. Design the logic for a program that allows a user to enter 10 numbers, then displays them in the reverse order of their entry. Answer: A sample solution follows Flowchart: Pseudocode: start Declarations num index num SIZE = 10 num numbers[SIZE] = 0,0,0,0,0,0,0,0,0,0 getReady() while index < SIZE getNumbers() endwhile finishUp() stop getReady() index = 0 return getNumbers() output “Enter a number for position ”, index input numbers[index] index = index + 1 return finishUp() output “The numbers in reverse order are: ” while index > 0 index = index – 1 output numbers[index] endwhile return b. Modify the reverse-display program so that the user can enter up to 10 numbers until a sentinel value is entered. Answer: A sample solution follows Flowchart: Pseudocode: start Declarations num index num SIZE = 10 num numbers[SIZE] = 0,0,0,0,0,0,0,0,0,0 string CONTINUE = “Y” string moreNumbers = CONTINUE getReady() while index < SIZE AND moreNumbers equal to CONTINUE getNumbers() endwhile finishUp() stop getReady() index = 0 output “Do you want to enter a number? (Y/N)” input moreNumbers return getNumbers() output “Enter a number for position ”, index input numbers[index] index = index...

Words: 4366 - Pages: 18

Free Essay

Jesus

...javax.microedition.lcdui Class TextField java.lang.Object | +--javax.microedition.lcdui.Item | +--javax.microedition.lcdui.TextField public class TextField extends Item A TextField is an editable text component that may be placed into a Form. It can be given a piece of text that is used as the initial value. A TextField has a maximum size, which is the maximum number of characters that can be stored in the object at any time (its capacity). This limit is enforced when the TextField instance is constructed, when the user is editing text within the TextField, as well as when the application program calls methods on the TextField that modify its contents. The maximum size is the maximum stored capacity and is unrelated to the number of characters that may be displayed at any given time. The number of characters displayed and their arrangement into rows and columns are determined by the device. The implementation may place a boundary on the maximum size, and the maximum size actually assigned may be smaller than the application had requested. The value actually assigned will be reflected in the value returned by getMaxSize(). A defensively-written application should compare this value to the maximum size requested and be prepared to handle cases where they differ. Input Constraints The TextField shares the concept of input constraints with the TextBox object. The different constraints allow the application to request that the user's input be restricted in a variety of ways...

Words: 3677 - Pages: 15

Free Essay

Cs205

...Assignment 2 1. Write a function that takes an array of int as a parameter and returns a count of odd numbers in the array.  Assume the array has MAX elements where MAX is a global constant int.  That means that before all of the functions there is a declaration like: const int MAX = 10; And arrays are declared like: int myArray[MAX]; Note: if you are having trouble with the array questions, be sure to work through the “Building Block” problems in this module first. 2. Write a function that takes an array of int as a parameter and returns the sum of odd numbers in the array.  Assume the array has MAX elements where MAX is a global constant int. 3. Rewrite your answer to the previous question as a recursive function. 4. Write a function that is passed two parameters: a one-dimensional array of int values, and an int value.   The function finds the value in the array that is closest in value to the second parameter.  For example, if the array had the values {5, -3, 18, 9, 4} and the second parameter was 11, then the function would return 9, because 9 is the closest value in the array to 11. If two values are equally distant, return either.  In the previous example, if the second parameter was 7, either 5 or 9 could be returned. Assume the array has MAX elements where MAX is a global constant int. 5. Write a function that initializes the components of a two-dimensional array in the following manner: components above the upper-left to lower-right diagonal should be set...

Words: 472 - Pages: 2

Free Essay

C Language

...Handout: Problem Solving and 'C' Programming Version: PSC/Handout/1107/1.0 Date: 16-11-07 Cognizant 500 Glen Pointe Center West Teaneck, NJ 07666 Ph: 201-801-0233 www.cognizant.com Problem Solving and C Programming TABLE OF CONTENTS About this Document ....................................................................................................................6 Target Audience ...........................................................................................................................6 Objectives .....................................................................................................................................6 Pre-requisite .................................................................................................................................6 Session 2: Introduction to Problem Solving and Programming Languages ...........................7 Learning Objectives ......................................................................................................................7 Problem Solving Aspect ...............................................................................................................7 Program Development Steps .......................................................................................................8 Introduction to Programming Languages ...................................................................................14 Types and Categories of Programming Languages...

Words: 4320 - Pages: 18