Important Notes Pay attention to file names!!! You must name them what we tell you to. mkdir – make a folder (make the ones we tell you to) rm – remove.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Warm up Determine the value stored in each of the following: – gradeTable[ 0 ][ 0 ] – gradeTable[ 1 ][ 1 ] – gradeTable[ 3 ][ 4 ] – gradeTable[ 5 ][ 2.
BUILDING JAVA PROGRAMS CHAPTER 3 PARAMETERS AND OBJECTS.
More Java Syntax. Scanner class Revisited The Scanner class is a class in java.util, which allows the user to read values of various types. There are.
CSCI S-1 Section 5. Deadlines for Problem Set 3 Part A – Friday, July 10, 17:00 EST Parts B – Tuesday, July 14, 17:00 EST Getting the code examples from.
Mock test review Revision of Activity Diagrams for Loops,
2  An instruction or group of instructions need to be repeated several times.  2 types of iteration: 1.You do not know how many times you will need.
CS 177 Recitation Week 8 – Methods. Questions? Announcements  Project 3 milestone due next Thursday 10/22 9pm  Turn in with: turnin –c cs177=xxxx –p.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
Nested For Loops It is also possible to place a for loop inside another for loop. int rows, columns; for (rows=1; rows
Copyright 2008 by Pearson Education Building Java Programs Chapter 4 Lecture 4-1: Scanner ; if/else reading: , 4.2, 4.6.
LAB 10.
Multi-Dimensional Arrays Rectangular & Jagged Plus: More 1D traversal.
Topic 11 Scanner object, conditional execution Copyright Pearson Education, 2010 Based on slides bu Marty Stepp and Stuart Reges from
Computer Programming Lab(5).
Hello AP Computer Science!. What are some of the things that you have used computers for?
Introduction to Information and Computer Science Computer Programming Lecture c This material (Comp4_Unit5c), was developed by Oregon Health and Science.
Introduction to Information and Computer Science Computer Programming Lecture d This material (Comp4_Unit5d) was developed by Oregon Health and Science.
1 Introduction to Java Brief history of Java Sample Java Program Compiling & Executing Reading: => Section 1.1.
Slides prepared by Rose Williams, Binghamton University Chapter 2 Console Input and Output.
BUILDING JAVA PROGRAMS CHAPTER 2 Days of For Loops Past.
CSCI S-1 Section 6. Coming Soon Homework Part A – Friday, July 10, 17:00 EST Homework Part B – Tuesday, July 14, 17:00 EST Mid-Term Quiz Review – Friday,
October 28, 2015ICS102: For Loop1 The for-loop and Nested loops.
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 4.
Can we talk?. In Hello World we already saw how to do Standard Output. You simply use the command line System.out.println(“text”); There are different.
Introduction to Programming
CHAPTER 5 GC 101 Input & Output 1. INTERACTIVE PROGRAMS  We have written programs that print console output, but it is also possible to read input from.
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Review :chapters What is an algorithm? A step by step description of how to accomplish a task. For example, Adding 3 numbers N1, N2 and N3 Add.
Reading input from the console input. Java's console input The console is the terminal window that is running the Java program I.e., that's the terminal.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC141 Computer Science I 2/4/20161.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING String and Scanner Objects.
 CSC111 Quick Revision. Problem Write a java code that read a string, then show a list of options to the user to select from them, where:  L to print.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
1 Simple Input Interactive Input - The Class Scanner n Command-Line Arguments.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING For Loop.
CPSC 233 Tutorial Xin Liu Feb 14, Tips on keyboard input How to detect that the user just hit enter when prompted for a string import java.util.Scanner;
Building Java Programs Chapter 4 Lecture 4-1: Scanner ; cumulative algorithms reading: 3.3 – 3.4, 4.2.
Copyright 2008 by Pearson Education Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: self-check: #16-19.
Chapter 9 Introduction to Arrays Fundamentals of Java.
Chapter 2 Clarifications
Exercise 1- I/O Write a Java program to input a value for mile and convert it to kilogram. 1 mile = 1.6 kg. import java.util.Scanner; public class MileToKg.
Suppose we want to print out the word MISSISSIPPI in big letters.
CSC1401 Input and Output (and we’ll do a bit more on class creation)
Maha AlSaif Maryam AlQattan
Repetition.
Topic 11 Scanner object, conditional execution
Something about Java Introduction to Problem Solving and Programming 1.
INPUT STATEMENTS GC 201.
Decision statements. - They can use logic to arrive at desired results
CSS161: Fundamentals of Computing
Michele Weigle - COMP 14 - Spr 04
مساق: خوارزميات ومبادئ البرمجة الفصل الدراسي الثاني 2016/2015
Introduction to Classes and Methods
SELECTION STATEMENTS (2)
File Handling in Java January 19
class PrintOnetoTen { public static void main(String args[]) {
Building Java Programs
Building Java Programs
Factoring if/else code
Introduction to Java Brief history of Java Sample Java Program
Module 4 Loops and Repetition 4/7/2019 CSE 1321 Module 4.
Scope of variables class scopeofvars {
Building Java Programs
Building Java Programs
Presentation transcript:

Important Notes Pay attention to file names!!! You must name them what we tell you to. mkdir – make a folder (make the ones we tell you to) rm – remove files (don’t do this unless you are sure you want to remove them) *, tab complete, up arrow, mv Any questions on FTP??

Debugging Exercise Name the three errors in the following program: public class FamousSpeech public static void main(String [ ]) { System.out.println(“Four score and seven years ago,”); System.out.println(“…”); /* this part should say System.out.println(“…”); the rest of the speech */ }

Correct Version Name the three errors in the following program: public class FamousSpeech { public static void main(String [ ] args) { System.out.println(“Four score and seven years ago,”); System.out.println(“…”); // this part should say System.out.println(“…”); // the rest of the speech }

Procedural Decomposition Public class Confusing { public static void method2() { method1(); System.out.println(“I am method 2.”); } public static void method3() { method2(); System.out.println(“I am method 3.”); public static void method1() { System.out.println(“I am method 1.”); public static void main(String[] args) { method1(); method3(); method2(); }

Identifiers Which of the following can be used in a Java program as identifiers? println first-name AnnualSalary “hello” ABC 42isTheAnswer for sum_of_data _average B4

Identifiers Which of the following can be used in a Java program as identifiers? AnnualSalary ABC sum_of_data B4

Design Imagine you are writing a personal fitness program that stores the user’s age, gender, height (in feet or meters), and weight (to the nearest pound or kilogram). Declare variables with the appropriate names and types to hold this information.

Nested For Loops Write a program that prints out the multiplication table.

Nested For Loops Write a program the prints out the multiplication table. for(int row = 1; row <= 10; row ++) { for(int col = 1; col <= 10; col ++) { System.out.print(row*col); System.out.print(“\t“); } System.out.println();

Importing Classes and Input import java.util.*; Scanner keyboard = new Scanner (System.in); int inputName = keyboard.nextInt(); Go to example input.java