Maha AlSaif Maryam AlQattan

Slides:



Advertisements
Similar presentations
Computer Programming Lab(7).
Advertisements

Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
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.
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Class Design Lecture 6, Tue Jan
Java Intro. Strings “This is a string.” –Enclosed in double quotes “This is “ + “another “ + “string” –+ concatenates strings “This is “ “ string”
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
***** SWTJC STEM ***** Chapter 3-1 cg 36 Java Class Libraries & API’s A class library is a set of classes that supports the development of programs. Java.
LAB 10.
Computer Programming Lab(4).
Computer Programming Lab(5).
1 Introduction to Java Brief history of Java Sample Java Program Compiling & Executing Reading: => Section 1.1.
Java Fundamentals 3 Input and Output statements. Standard Output Window Using System.out, we can output multiple lines of text to the standard output.
Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Chapter 5 Loops.
Input/Output in Java. Output To output to the command line, we use either System.out.print () or System.out.println() or System.out.printf() Examples.
Outline Creating Objects The String Class The Random and Math Classes Formatting Output Enumerated Types Wrapper Classes Components and Containers Images.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Miscellaneous topics Chapter 2 Savitch. Miscellaneous topics Standard output using System.out Input using Scanner class.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) public static void main(String[]
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC1401 Strings (text). Learning Goals Working with Strings as a data type (a class) Input and output of Strings String operations.
Chapter 6. else-if & switch Copyright © 2012 Pearson Education, Inc.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
String and Scanner CS 21a: Introduction to Computing I First Semester,
Java Basics Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 M.A. Papalaskari, Villanova University Algorithms Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
 2005 Pearson Education, Inc. All rights reserved. 1 Introduction to Classes and Objects.
Martin T. Press.  Main Method and Class Name  Printing To Screen  Scanner.
 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.
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.
Interactive Programs Programs that get input from the user 1 In PowerPoint, click on the speaker icon then click the "Play" button to hear the narration.
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
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;
Copyright 2008 by Pearson Education Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: self-check: #16-19.
Introduction to programming in java
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC111 Quick Revision.
File I/O CLI: File Input CLI: File Output GUI: File Chooser
Introduction to programming in java
TemperatureConversion
Project 1.
CSC1401 Input and Output (and we’ll do a bit more on class creation)
Compiling and Running a Java Program
CSC 1051 – Data Structures and Algorithms I
Chapter 6 More Conditionals and Loops
Something about Java Introduction to Problem Solving and Programming 1.
INPUT STATEMENTS GC 201.
Control Statement Examples
Introduction to Classes and Methods
September 9, 2008 Lecture 5 – More IO.
L3. Necessary Java Programming Techniques
L3. Necessary Java Programming Techniques
Class Examples.
September 9, 2008 Lecture 5 – More IO.
Introduction to Java Brief history of Java Sample Java Program
Module 4 Loops and Repetition 4/7/2019 CSE 1321 Module 4.
CSE Module 1 A Programming Primer
Module 3 Selection Structures 4/5/2019 CSE 1321 Module 3.
Debugging Exercise 00 Try compiling the code samples.
Outline Boolean Expressions The if Statement Comparing Data
Array Review Selection Sort
CSS161: Fundamentals of Computing
Repetition CSC 1051 – Data Structures and Algorithms I Course website:
Presentation transcript:

Maha AlSaif 200800420 Maryam AlQattan 200900025 Java Exercises Maha AlSaif 200800420 Maryam AlQattan 200900025

Find the three errors in the following code. import java.util.Scanner public class Echo { //----------------------------------------------------------------- // Reads a character string from the user and prints it. public static void main (String[ args) String message; Scanner scan = new Scanner (System.in); System.out.println (“What is your name?"); message = scan.nextLine(); System.out.println ("You entered: \"" + message + "\""); } }

Add Remove import java.util.Scanner; public class Echo { //----------------------------------------------------------------- // Reads a character string from the user and prints it. public static void main (String[] args) String message; Scanner scan = new Scanner (System.in); System.out.println (“What is your name?"); message = scan.nextLine(); System.out.println ("You entered: \"" + message + "\""); } } Add Remove

What is the code used to create this output?

The code..