Input, Variables, and Mathematical Expressions

Slides:



Advertisements
Similar presentations
ARDUINO CLUB Session 1: C & An Introduction to Linux.
Advertisements

Python November 14, Unit 7. Python Hello world, in class.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
1 Introduction to Computers and Programming Class 3 Introduction to C Professor Avi Rosenfeld.
Scanner & Stepwise Refinement Pepper With credit to Dr. Siegfried.
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;
Week 2 - Friday.  What did we talk about last time?  Data representation  Binary numbers  Types  int  boolean  double  char  String.
Week #2 Java Programming. Enable Line Numbering in Eclipse Open Eclipse, then go to: Window -> Preferences -> General -> Editors -> Text Editors -> Check.
Expressions, Data Conversion, and Input
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 9, 2015)
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Week 2 - Wednesday.  What did we talk about last time?  Data representation  Binary numbers  Types  int  boolean  double  char  String.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Please log on The. AN INTRODUCTION TO ‘Python is a high-level, general purpose programming language’ Python is one of the many programming languages.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
UFCEKS-20-2Multimedia Authoring Times Table Quiz.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
Math, Data Types. Python Math Operations OperationOperator Addition + Subtraction – Multiplication * Division (floating point) / Division (integer) //
Cosc175/operators1 Algorithms computer as the tool process – algorithm –Arithmetic: addition,subtraction,multiplication,division –Save information for.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
Variables Continued In the last session we saw how variables are objects that allow us to store values in the RAM of the computer In this session we shall.
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
1 Arrays of Arrays Quick review … arrays Arrays of arrays ≡ multidimensional array Example: times table Representation in memory Ragged arrays Example:
Primitive Data Types int is a primitive data type A primitive data type is one that stores only a single piece of data. TypeStorageDescription int 4 bytes+ve.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
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.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Making Interactive Programs with Visual Basic .NET
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Input, Output and Variables GCSE Computer Science – Python.
Loops Review. How to generate random numbers Math.random() will return a random decimal value in the form of a double. double num1 = Math.random(); num1.
Foundations of Programming: Java
CompSci 230 S Programming Techniques
User Input ICS2O.
Chapter 2 Clarifications
Chapter 2 Basic Computation
Chapter 2 More on Math More on Input
Data Types and Conversions, Input from the Keyboard
Chapter 3: Variables, Functions, Math, and Strings
Chapter 7 Part 1 Edited by JJ Shepherd
Variables, Expressions, and IO
User input We’ve seen how to use the standard output buffer
Chapter 2 Basic Computation
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
A+ Computer Science INPUT.
Lecture Notes 8/24/04 (part 2)
Lec 4: while loop and do-while loop
Variables and Expressions
Chapter 3 – Introduction to C# Programming
Algorithms computer as the tool process – algorithm
Introduction to Value-Returning Functions: Generating Random Numbers
A+ Computer Science INPUT.
Java Programming First Program and Variables
Java: Variables, Input and Arrays
Multiply and divide Expressions
Data Type Conversion ICS2O.
DATA TYPES AND OPERATIONS
Presentation transcript:

Input, Variables, and Mathematical Expressions By James H

Input Input definition: To enter information or data into a form of input element such as a textbox, text field, text entry box etc. The user can input anything into these input elements as data This data can be put into a variable box for the program to remember and use later.

Basic Input Commands Import the scanner library of codes at the top: Import Java.util.scanner; Set up scanner class: Scanner scan1=new Scanner(System.in); Prompt respond to input request: System.out.println("What is your name?:"); Scan and input it in a variable: a=scanl.nextInt(); b=scanl.nextDouble(); c=scanl.nextLine();

Variables Variables are storable boxes located in the computer’s RAM (Random Access Memory) Variables can be labeled under any name by the programmer These variables can store many forms of values such as text, numbers and decimals. Values can be either predetermined by the programmer or values that the user has inputted as well.

Basic Variable Commands Declares an integer variable int num=666; Declares a double variable (decimals) Double num=6.8; Declares a string variable String pricey= “wow”;

Mathematical Expression Mathematical expressions are commands that allow the program to perform basic math on variables such as addition, subtraction, multiplication etc. Basic Commands: Perform addition on “num” and store it as a new variable Int num2=num+1; Perform subtraction on “num” and store it as a new variable Int num2=num-1; Perform multiplication on “num” and store it as a new variable Int num2=num*1; Perform division on “num” and store it as a new variable Int num2=num/1;

Purpose Asking the user to input data allows the program to use this information at anytime by accessing the variable assigned Since the user can input any form of data, it adds variation to how the program will run Depending on what the user inputs into a variable, the program can respond differently to what the user has inputted. The program can also manipulate data in variables, for example if the user enters a number you can add, subtract, multiply etc. that value Thus, the program has infinite possibility of what data it can store, manipulate, and output.

Command Example: Import Java.util.scanner; (assume this is at the very top) String name=""; Int age=0; Scanner scanl=new Scanner(System.in); System.out.println("What is your name?:"); name=scanl.nextString(); System.out.println("How old are you?:"); age=scanl.nextInt(); Int age2 = age+1; System.out.println("Your name is “+name+” and you are turning “+age2+” next year.”);

The End