Seating “chart” Front Back 4 rows 5 rows 5 rows 4 rows 2 rows 2 rows

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 2 Simple C Programs.
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.
Intro to CS – Honors I Control Flow: Loops GEORGIOS PORTOKALIDIS
BBS514 Structured Programming (Yapısal Programlama)1 Functions and Structured Programming.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
CS150 Introduction to Computer Science 1
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
Basic Input/Output and Variables Ethan Cerami New York
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
Java Programming: From the Ground Up
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Loops: Handling Infinite Processes CS 21a: Introduction to Computing I First Semester,
Chapter 5 Loops.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Lecture 5: Stopping with a Sentinel. Using a Sentinel Problem Develop a class-averaging program that will process an arbitrary number of grades each time.
CS 240 – Computer Programming I Lab Kalpa Gunaratna –
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Looping.
1 Chapter 2: Java Fundamentals cont’d Spring Lory Al Moakar.
Digesting a big problem ONE BYTE AT A TIME. Quiz YOU WILL WORK WITH YOUR PARTNER (LAB PARTNER NOT FULL TEAM). FOR SOLOISTS OR THOSE WHOSE PARTNER IS NOT.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
Midterm 2 Review. Stars and why we use nested loops  Matrix problems (stars)  Other problems involving multiple dimensions  Loops within a process.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
1 Project 4: Computing Distance. 222 Computing Distance Write a program to compute the distance between two points. Recall that the distance between the.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
CSC111 Quick Revision.
User-Written Functions
MATLAB – More Script Files
Chapter 2 More on Math More on Input
Chapter 6: Modular Programming
Control Statements: Part 1
Chapter 2 Assignment and Interactive Input
Variables, Expressions, and IO
Chapter 4 – Control Structures Part 1
Lecture 07 More Repetition Richard Gesick.
Lecture 4B More Repetition Richard Gesick
Computer Science 210 Computer Organization
Starting Out with Java: From Control Structures through Objects
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Outline Altering flow of control Boolean expressions
Number and String Operations
Programming Funamental slides
TIPS: How to Be Successful
Programming Funamental slides
1) C program development 2) Selection structure
Chapter 4 Loops While loop The for loop do… while break and continue
Chapter 6: Repetition Statements
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
Programming Fundamentals (750113) Ch1. Problem Solving
Functions continued.
Programming Fundamentals (750113) Ch1. Problem Solving
Other types of variables
CS 101 First Exam Review.
Unit 3: Variables in Java
More Loops Topics Relational Operators Logical Operators for Loops.
Announcements Lab 3 was due today Assignment 2 due next Wednesday
CSCE 206 Lab Structured Programming in C
Introduction to C Programming
EECE.2160 ECE Application Programming
CHAPTER 6 Testing and Debugging.
Presentation transcript:

Seating “chart” Front Back 4 rows 5 rows 5 rows 4 rows 2 rows 2 rows

Quiz You will work with your partner (Lab partner not full team). You will have 20 minutes.

Quiz Grading Pass your quiz to another team in a different section than you. As we go over each question, grade it based on the points and result.

Question 1 Which of the following is not a valid assignment statement, assuming all variables have been declared and initialized with an appropriate data type? total = sum + next; keyboard.nextInt() = value; count = count + flag; rate = 10.2;

Question 2 WhichCar.java:44: possible loss of precision found : double required: int cost = totalCost; What is the possible cause of this error? cost has not been declared cost has not been initialized totalCost has not been initialized cost is an int and totalCost is a double

Question 3 WhichCar.java:44: possible loss of precision found : double required: int cost = totalCost; On what line number in the source file does this error occur? Line 0 Line 15 Line 44 It is impossible to tell from the error message provided

Question 4

Question 5 Declare a String variable named state. Then initialize the variable so it references an object with the string “Virginia”. String state; state = “Virginia”; OR state = new String (“Virginia”);

Question 6 Does the following statement compute the average of double variables a, b, and c? Why or why not? Explain double average = a + b + c / 3.0; 1pt – NO 1pt – The c will be divided by 3 first and then that result will be added to a + b.

Question 7 Which of the following assignments are valid, given that the following variables are declared:   int cost, double taxRate, float interestRate, long count interestRate = taxRate; cost = taxRate; count = cost; cost = count;

Question 8 block of statements Enclosing a group of statements inside a set of braces creates a   block of statements boolean expression loop Nothing, it is just for readability

Practice - Solve a problem in pieces. In your teams, work on the following problem: The distance between any two points, (x1y1 and x2y2) can be computed by the formula: Write a program to read in from the user the point values and then compute and print the distance in the form of: The distance between (x1y1) and (x2y2) is XXXX.XX.

Think about this problem as a problem in 3 parts. Part 1 – Reading in the input. Think about the variables you will need. (At least one variable for each individual component of the points and a Scanner) and declare them. Think about how you will prompt the user. Perform the read operations to load the variables. Note: if you are writing the program, you could stop here and test by “echoing” the input via a temporary println to show that the variables hold the correct values.

Part 2 Calculating the result Think about any additional variables you will need and declare them up top. Create the calculation. Note that while this is a single formula, you might do better by breaking it down. Two Math class methods that might be useful are Math.pow() and Math.sqrt. At this point you can test to see that the calculation is working correctly. If you are using sub calculations, you can also test them by putting in additional print statements.

Part 3 – Making the format pretty Now that you have the program producing the correct result, add in print statements to display the result. Use the DecimalFormat class (another variable) if you wish or printf. If this is working correctly, you can then remove all of the unnecessary print statements that you used for testing.

Homework Finish up the work on this algorithm. You will be writing this program as one part of the work of Tuesday’s lab. There will be a weekly quiz and the focus will be on arithmetic operations.