CS 11 – April 1 Review steps for lab #3

Slides:



Advertisements
Similar presentations
1 Todays Objectives Announcements Homework #1 is due next week Return Quiz 1 – answers are posted on the Yahoo discussion page site Basic Java Programming.
Advertisements

This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Computer Programming Lab(7).
1 Various Methods of Populating Arrays Randomly generated integers.
Computer Programming Lab 8.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Case studies over control structures and iterative structures Instructor – Gokcen Cilingir Cpt S 121 (July 6, 2011) Washington State University.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
True BASIC Ch. 6 Practice Questions. What is the output? PRINT X LET X = -1 PRINT X FOR X = 4 TO 5 STEP 2 PRINT X NEXT X PRINT X END.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
CS150 Introduction to Computer Science 1
Flowcharts Remember that a solution to a problem is called an algorithm. Algorithms are often a series of steps required to solve the problem. A flowchart.
1 10/9/06CS150 Introduction to Computer Science 1 for Loops.
CHAPTER 2 ANALYSIS OF ALGORITHMS Part 2. 2 Running time of Basic operations Basic operations do not depend on the size of input, their running time is.
High-Level Programming Languages: C++
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Discussion 5. Lab 3 Not really using rectangle class Return type of getPoint is String instead of Point You are not able to retrieve the point if you.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
DT249-Information Systems Research Practice Programming Revision Lecture 2 Lecturer: Patrick Browne.
Before we get started…. First, a few things… Weighted Grading System Programming Style Submitting your assignments… The char and string variable types.
1 Project 3 String Methods. Project 3: String Methods Write a program to do the following string manipulations: Prompt the user to enter a phrase and.
1 Project 1: Tickets. 2 Class Ticket Write a definition for class Ticket. A Ticket object corresponds to a physical ticket for a stage show. Attributes.
COMP Loop Statements Yi Hong May 21, 2015.
Homework 1 (due:April 8th) Deadline : April 8th 11:59pm Where to submit? eClass “ 과제방 ” ( How to submit? Create a folder. The name.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Designing with While loops.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 4 Loops.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS 1 Copyright: 2015 Illinois Institute of Technology_ George Koutsogiannakis.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Homework 1 (due:April 13th) Deadline : April 13th 11:59pm Where to submit? eClass 과제방 ( How to submit? Create a folder. The name.
1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.
Lecture 4 CS140 Dick Steflik. Reading Keyboard Input Import java.util.Scanner – A simple text scanner which can parse primitive types and strings using.
EECS 183 Discussion #10: I’m actually Alex Trebek. November 15th, 2016
C++ Memory Management – Homework Exercises
Review 1.
CSC111 Quick Revision.
Introduction to programming in java
CS 160 Final Review.
CS139 – PA3 Intro.
Chapter 8 – Arrays and Array Lists
Introduction To Repetition The for loop
Yanal Alahmad Java Workshop Yanal Alahmad
5. Function (2) and Exercises
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
CS 177 Week 15 Recitation Slides
Python I/O.
CS 2308 Exam I Review.
Computers & Programming Languages
Flow of Control October 16, 2017.
In Class Program: Today in History
Unary Operators ++ and --
More Loops.
CSCE 206 Lab Structured Programming in C
Count Controlled Loops (Nested)
CS 1428 Final Exam Review.
For Loops.
Lec 4: while loop and do-while loop
Class Examples.
Looping III (do … while statement)
OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS
Seating “chart” Front Back 4 rows 5 rows 5 rows 4 rows 2 rows 2 rows
INC 161 , CPE 100 Computer Programming
Functions continued.
Homework 1 (due:April 17th)
DATA STRUCTURES 5/3/2019© 2006 ITT Educational Services Inc.
CSCE 206 Lab Structured Programming in C
CSCE 206 Lab Structured Programming in C
Computer Science Club 1st November 2019.
Presentation transcript:

CS 11 – April 1 Review steps for lab #3 Finish monthly climate problem. Array of objects Convenient to organize into 3 source files. Searching an array of objects is similar to searching array of numbers, or characters in a string. findMax() – search array for an attribute findMin() – search array for an object No class tomorrow; please submit homework design by Thursday.

Team.java Declare attributes: 1 string, 3 int Declare constant GOOD = 95 Initial-value constructor This is where attributes are initialized. findTotalPoints() isGood() Since we need to know the number of points, we need to call findTotalPoints( ) within isGood( ). You don’t need to make points an attribute, because it can be derived from other values.

Driver.java Ask user for number of teams Use nextInt( ) to read this number  numTeams Initialize count and numGood to 0 Set up while-loop to run numTeams iterations: Ask user for a name and 3 numbers Read string and 3 integers Create team object by calling Team constructor Call toString( ) to print out the object. Call isGood( ), and if true, increment numGood Print the number of good teams

Driver2.java Change program to use file I/O. Ask user for names of input & output files Read these names from keyboard. Open the input and output files. Read first number from file  numTeams Take out prompt asking user for this number Inside while loop: Change the scanner calls so we read from the input file instead of from the keyboard

Monthly climate The most interesting part of the program is the Month class. Constructor reads input file. Each line corresponds to one day. Read the 4 numbers, create Day object, put in array. Traversing an array I implemented findMax( ) and findMin( ) differently so you could see the difference between finding an object versus just one attribute value. findTotalRain( ) just sums the rain attribute for each Day.