CSE Module 1 A Programming Primer

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

Programming Methodology (1). Implementing Methods main.
Today’s topics: I/O (Input/Output). Scribbler Inputs & Outputs  What are the Scribbler’s inputs and outputs?  reset button  motors/wheel  light sensor.
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.
Reading Information From the User Making your Programs Interactive.
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
LAB 10.
MSc IT Programming Methodology (2). MODULE TEAM Dr Aaron Kans Dr Sin Wee Lee.
1 Scanner objects. 2 Interactive programs We have written programs that print console output. It is also possible to read input from the console.  The.
Computer Programming Lab(5).
Console Input. So far… All the inputs for our programs have been hard-coded in the main method or inputted using the dialog boxes of BlueJ It’s time to.
Java Fundamentals 3 Input and Output statements. Standard Output Window Using System.out, we can output multiple lines of text to the standard output.
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.
Miscellaneous topics Chapter 2 Savitch. Miscellaneous topics Standard output using System.out Input using Scanner class.
Chapter 6. else-if & switch Copyright © 2012 Pearson Education, Inc.
CSE 1341 Honors Note Set 05 Professor Mark Fontenot Southern Methodist University.
FUNDAMENTALS 2 CHAPTER 2. OPERATORS  Operators are special symbols used for:  mathematical functions  assignment statements  logical comparisons 
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
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.
Introduction to Computing Concepts Note Set 15. JOptionPane.showMessageDialog Message Dialog Allows you to give a brief message to the user Can be used.
Formatted Output (printf) CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
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.
© 2007 Lawrenceville Press Slide 1 Chapter 4 Review Assignment Statement An assignment statement gives a value to a variable. Assignment can take several.
Computer Programming Lab 9. Exercise 1 Source Code package excercise1; import java.util.Scanner; public class Excercise1 { public static void main(String[]
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Class Everything in Java is in a class. The class has a constructor that creates the object. If you do not supply a constructor Java will create a default.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Introduction to programming in java
Introduction of Java Fikri Fadlillah, S.T.
CompSci 230 S Programming Techniques
CSC111 Quick Revision.
TemperatureConversion
CS 201 Lecture 7: John Hurley Summer 2012 Cal State LA.
CSC1401 Input and Output (and we’ll do a bit more on class creation)
John Hurley CS201 Cal State LA
CSCI 161 – Introduction to Programming I William Killian
Maha AlSaif Maryam AlQattan
User input We’ve seen how to use the standard output buffer
Introduction to Methods in java
Repetition.
Topic 11 Scanner object, conditional execution
Something about Java Introduction to Problem Solving and Programming 1.
INPUT STATEMENTS GC 201.
מבוא למדעי המחשב, סמסטר א', תשע"א תרגול מס' 2
Computers & Programming Languages
Introduction to Classes and Methods
September 9, 2008 Lecture 5 – More IO.
בתרגול הקודם אתר הקורס (הודעות, פרטי סגל הקורס, עבודות, פורום, מערכת הגשת תרגילים וכו') שימוש בחלון ה-command, פקודות בסיסות קוד Java: הידור (= קומפילציה)
class PrintOnetoTen { public static void main(String args[]) {
Building Java Programs
September 9, 2008 Lecture 5 – More IO.
Chapter 2: Java Fundamentals
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Module 4 Loops and Repetition 4/7/2019 CSE 1321 Module 4.
Lecture 1 Review of 1301/1321 CSE /26/2018.
Module 3 Selection Structures 4/3/2019 CSE 1321 Module 3.
Methods and Data Passing
CSE Module 1 A Programming Primer
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Module 3 Selection Structures 4/5/2019 CSE 1321 Module 3.
CSE Module 1 A Programming Primer
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
CSE Module 1 A Programming Primer
CSE 1321 Modules 1-5 Review Spring 2019
Lecture 1 Review of 1301/1321 CSE /26/2018.
Repetition CSC 1051 – Data Structures and Algorithms I Course website:
Computer Science Club 1st November 2019.
CSE Module 1 A Programming Primer
Validation We have covered one way to get user input, using Scanner to get it from the console We will soon cover at least one additional way to get.
Optional Topic: User Input with Scanner
Presentation transcript:

CSE 1321 - Module 1 A Programming Primer 4/5/2019 CSE 1321 Module 1

Ps Skeletons BEGIN MAIN END MAIN Note: every time you BEGIN something, you must END it! Write them as pairs! 4/5/2019 CSE 1321 Module 1

Skeletons class MainClass { public static void main (String[] args) { } Note: Capitalization matters! 4/5/2019 CSE 1321 Module 1

Ps Printing BEGIN MAIN PRINT “Hello, World!” PRINT “Bob” + “ was” + “ here” END MAIN Ps 4/5/2019 CSE 1321 Module 1

Printing class MainClass { public static void main (String[] args) { System.out.println("Hello, World!"); System.out.println("Bob"+" was"+" here"); } Note: There’s also a System.out.print() 4/5/2019 CSE 1321 Module 1

Declaring/Assigning Variables BEGIN MAIN CREATE userName CREATE studentGPA userName ← “Bob” studentGPA ← 1.2 END MAIN userName “Bob” studentGPA 1.2 Ps 4/5/2019 CSE 1321 Module 1

Declaring/Assigning Variables class MainClass { public static void main (String[] args) { String userName; float gpa; userName = "Bob"; gpa = 1.2f; } 4/5/2019 CSE 1321 Module 1

Reading Text from the User BEGIN MAIN CREATE userInput PRINT “Please enter your name” READ userInput PRINT “Hello, ” + userInput END MAIN Ps 4/5/2019 CSE 1321 Module 1

Reading Text from the User import java.util.Scanner; class MainClass { public static void main (String[] args) { String userInput; System.out.print("Please enter your name: "); Scanner sc = new Scanner (System.in); userInput = sc.nextLine(); System.out.println("Hello, "+userInput); } 4/5/2019 CSE 1321 Module 1

Reading Numbers from the User BEGIN MAIN CREATE userInput PRINT “Please enter your age: ” READ userInput PRINT “You are ” + userInput + “ years old.” END MAIN Ps 4/5/2019 CSE 1321 Module 1

Reading Numbers from the User import java.util.Scanner; class MainClass { public static void main (String[] args) { int age; System.out.print("Please enter your age: "); Scanner sc = new Scanner (System.in); age = sc.nextInt(); System.out.println("You are "+age+" years old."); } 4/5/2019 CSE 1321 Module 1