KEMBAR78
Daftar
Login
ch02-IPO-Input-Process-Output-Input-Process-Output | PDF
Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
Submit search
EN
Uploaded by
ayeshazaveri4
23 views
ch02-IPO-Input-Process-Output-Input-Process-Output
ch02-IPO-Input-Process Output
Engineering
◦
Read more
0
Save
Share
Embed
Download
Download to read offline
1
/ 61
2
/ 61
3
/ 61
4
/ 61
5
/ 61
6
/ 61
7
/ 61
8
/ 61
9
/ 61
10
/ 61
11
/ 61
12
/ 61
13
/ 61
14
/ 61
15
/ 61
16
/ 61
17
/ 61
18
/ 61
19
/ 61
20
/ 61
21
/ 61
22
/ 61
23
/ 61
24
/ 61
25
/ 61
26
/ 61
27
/ 61
28
/ 61
29
/ 61
30
/ 61
31
/ 61
32
/ 61
33
/ 61
34
/ 61
35
/ 61
36
/ 61
37
/ 61
38
/ 61
39
/ 61
40
/ 61
41
/ 61
42
/ 61
43
/ 61
44
/ 61
45
/ 61
46
/ 61
47
/ 61
48
/ 61
49
/ 61
50
/ 61
51
/ 61
52
/ 61
53
/ 61
54
/ 61
55
/ 61
56
/ 61
57
/ 61
58
/ 61
59
/ 61
60
/ 61
61
/ 61
More Related Content
PPT
Chapter 01 - introduction for C++
by
wahida_f6
PPTX
Chapter 1 - Introduction to Programming and Visual Basic.pptx
by
SyntaxError25
PDF
Introduction to Computers and Programming
by
Edwin Flórez Gómez
PPT
Introduction to computers and programing.pptx
by
ahmedmidhu2001
PPT
programing fundamentals by dr. wheedh khan
by
ahmedmidhu2001
PPTX
SOW_C_CSO_Chapter_01_10e_a11y.pptx c++ chapter 1
by
alzawahramarkantony
PDF
Visual Logic Project - 1
by
Programming Techniques and Algorithms
PPT
Introduction to Programming
by
Chaffey College
Chapter 01 - introduction for C++
by
wahida_f6
Chapter 1 - Introduction to Programming and Visual Basic.pptx
by
SyntaxError25
Introduction to Computers and Programming
by
Edwin Flórez Gómez
Introduction to computers and programing.pptx
by
ahmedmidhu2001
programing fundamentals by dr. wheedh khan
by
ahmedmidhu2001
SOW_C_CSO_Chapter_01_10e_a11y.pptx c++ chapter 1
by
alzawahramarkantony
Visual Logic Project - 1
by
Programming Techniques and Algorithms
Introduction to Programming
by
Chaffey College
Similar to ch02-IPO-Input-Process-Output-Input-Process-Output
PPT
Chapter 2- Prog101.ppt
by
JosephObadiahTuray
PPT
1 Intro to Computers SOW_C++_CSO_Chapter_01_9e.ppt
by
azizt730
PDF
Chapter 2 Input,Processing and Output.pdf
by
laila287141
PPT
BookPPT_Chapter_01_9e.ppt
by
thaersyam
PDF
Fundamentals of Computer 20CS11T Chapter 5.pdf
by
THANMAY JS
PDF
Week 1
by
EasyStudy3
PPT
Input, Processing and Output
by
Munazza-Mah-Jabeen
PPT
presentation of java fundamental
by
Ganesh Chittalwar
PPTX
OOP Using Java Ch2 all about oop .pptx
by
doopagamer
PPTX
Introduction.pptx
by
ssusera8c91a
PPT
Unit 1 program development cycle
by
Dhana malar
PPT
Programming Fundamentals - Lecture 1.ppt
by
FarhanGhafoor7
PPT
Comp102 lec 1
by
Fraz Bakhsh
PPTX
Input output
by
nicky_walters
PDF
Programming Logic and Design Comprehensive 6th Edition Joyce Farrell
by
sathmethe
PPT
Cs 1114 - lecture-2
by
Zeeshan Sabir
PPT
Logic Formulation 2
by
deathful
PPTX
Chapter 01
by
gsanchez1
PDF
Introduction to programming by MUFIX Commnity
by
mazenet
PDF
Introduction To Programming (2009 2010)
by
SiliconExpert Technologies
Chapter 2- Prog101.ppt
by
JosephObadiahTuray
1 Intro to Computers SOW_C++_CSO_Chapter_01_9e.ppt
by
azizt730
Chapter 2 Input,Processing and Output.pdf
by
laila287141
BookPPT_Chapter_01_9e.ppt
by
thaersyam
Fundamentals of Computer 20CS11T Chapter 5.pdf
by
THANMAY JS
Week 1
by
EasyStudy3
Input, Processing and Output
by
Munazza-Mah-Jabeen
presentation of java fundamental
by
Ganesh Chittalwar
OOP Using Java Ch2 all about oop .pptx
by
doopagamer
Introduction.pptx
by
ssusera8c91a
Unit 1 program development cycle
by
Dhana malar
Programming Fundamentals - Lecture 1.ppt
by
FarhanGhafoor7
Comp102 lec 1
by
Fraz Bakhsh
Input output
by
nicky_walters
Programming Logic and Design Comprehensive 6th Edition Joyce Farrell
by
sathmethe
Cs 1114 - lecture-2
by
Zeeshan Sabir
Logic Formulation 2
by
deathful
Chapter 01
by
gsanchez1
Introduction to programming by MUFIX Commnity
by
mazenet
Introduction To Programming (2009 2010)
by
SiliconExpert Technologies
Recently uploaded
PPTX
Data types and datatype conversions of python programming.pptx
by
AmyPrasannaTella1
PDF
The CULTURIST Design Portfolio 2025 architecture and interior
by
design and architecture
PDF
An architecture to build high performance infrastructures on cloud computing ...
by
TELKOMNIKA JOURNAL
PPTX
Electrical_Draftsman_AutoCAD_Mastery_Roadmap.pptx
by
Ken Felix Lubega
PPTX
DECARBONAZING REFINING INDUSTRY rev2.pptx
by
gonzalezolabarriaped
PDF
Certified Cloud Security Professional (CCSP): Unit 4
by
VICTOR MAESTRE RAMIREZ
PDF
Somnath Mukherjee_BIM Specialist_Portfolio.pdf
by
SomnathMukherjee980757
PDF
Scenario-based WLAN Planning Design for Warehouse.pdf
by
omarlameda1
PPTX
Understanding UL Wire Options that Surpass Industry Standards
by
Epec Engineered Technologies
PPT
Research Design- Elements, types , characteristics
by
mythilymanivannanbme
PDF
Vertical Roller Mill more detail inside function
by
agungcemindo
PDF
energies-14-0ggggggggggggggggg2725-v2.pdf
by
CarlosPrezBuelga
PPTX
Optimizing Wave Energy Capture: Utilizing Variable-Pitch Turbine Blades in We...
by
Arijit Biswas
PPTX
Build an UWB Indoor Positioning System using ESP32 and Qorvo DWM3000
by
CircuitDigest
PDF
Somnath Mukherjee_BIM Specialist_Resume.pdf
by
SomnathMukherjee980757
PPTX
Hydrocarbon traps, migration and accumulation of petroleum
by
Ahmadnawaz144515
PDF
Replacing react with hotwire - Scot Ruby September 2025
by
pythonandchips
PDF
mariadbwebinardr07301000156458558219.pdf
by
Eduardo154255
PPTX
Basic presentation - architecture pics.pptx
by
MelsonJohnDalabajan
PDF
【EN】Accelerating Flutter UI Development with Figma Dev Mode MCP × Claude Code
by
Yuta Asada
Data types and datatype conversions of python programming.pptx
by
AmyPrasannaTella1
The CULTURIST Design Portfolio 2025 architecture and interior
by
design and architecture
An architecture to build high performance infrastructures on cloud computing ...
by
TELKOMNIKA JOURNAL
Electrical_Draftsman_AutoCAD_Mastery_Roadmap.pptx
by
Ken Felix Lubega
DECARBONAZING REFINING INDUSTRY rev2.pptx
by
gonzalezolabarriaped
Certified Cloud Security Professional (CCSP): Unit 4
by
VICTOR MAESTRE RAMIREZ
Somnath Mukherjee_BIM Specialist_Portfolio.pdf
by
SomnathMukherjee980757
Scenario-based WLAN Planning Design for Warehouse.pdf
by
omarlameda1
Understanding UL Wire Options that Surpass Industry Standards
by
Epec Engineered Technologies
Research Design- Elements, types , characteristics
by
mythilymanivannanbme
Vertical Roller Mill more detail inside function
by
agungcemindo
energies-14-0ggggggggggggggggg2725-v2.pdf
by
CarlosPrezBuelga
Optimizing Wave Energy Capture: Utilizing Variable-Pitch Turbine Blades in We...
by
Arijit Biswas
Build an UWB Indoor Positioning System using ESP32 and Qorvo DWM3000
by
CircuitDigest
Somnath Mukherjee_BIM Specialist_Resume.pdf
by
SomnathMukherjee980757
Hydrocarbon traps, migration and accumulation of petroleum
by
Ahmadnawaz144515
Replacing react with hotwire - Scot Ruby September 2025
by
pythonandchips
mariadbwebinardr07301000156458558219.pdf
by
Eduardo154255
Basic presentation - architecture pics.pptx
by
MelsonJohnDalabajan
【EN】Accelerating Flutter UI Development with Figma Dev Mode MCP × Claude Code
by
Yuta Asada
ch02-IPO-Input-Process-Output-Input-Process-Output
1.
Starting out with
Programming Logic and Design Sixth Edition Chapter 2 Input, Processing, and Output Copyright © 2022, 2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved
2.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved Learning Objectives 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types 2.5 Named Constants 2.6 Hand Tracing a Program 2.7 Documenting a Program 2.8 Designing Your First Program 2.9 Focus on Languages: Java, Python, and C++
3.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.1 Designing a Program (1 of 7) 1. The first step in programming is designing – flowcharts and pseudocode help with this process. 2. Next, the code is written. 3. All code must be cleared of all syntax errors. 4. After the executable is created, it can be checked for logic errors. 5. If logic errors exist, the program must be debugged.
4.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.1 Designing a Program (2 of 7) The purpose of Programming Logic and Design is to focus on Flowcharts and Pseudocode. The design is the foundation of a good program. The program development cycle
5.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.1 Designing a Program (3 of 7) Two steps in designing a program 1. Understand the tasks that the program is to perform. – Learning what the customer wants. 2. Determine the steps that must be taken to perform the task. – Create an algorithm, or step-by-step directions to solve the problem. – Use flowcharts and/or pseudocode to solve.
6.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.1 Designing a Program (4 of 7) Pseudocode • Fake code used as a model for programs • No syntax rules • Well written pseudocode can be easily translated to actual code Display "Enter the number of hours" Input hours Display "Enter the hourly pay rate" Input payRate Set grossPay = hours * payRate Display "The gross pay is $", grossPay
7.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.1 Designing a Program (5 of 7) Flowcharts • A diagram that graphically depicts the steps that take place in a program Figure 2-2 Flowchart for the pay calculating program
8.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.1 Designing a Program (6 of 7) • Flowchart Connector Symbol – Use connectors to break a flowchart into two or more smaller flowcharts and placing them side- by-side on the page.
9.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.1 Designing a Program (7 of 7) • Off-Page Connector Symbol – To connect flowcharts on different pages
10.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.2 Output, Input, and Variables (1 of 6) Output – data that is generated and displayed Input – data that a program receives Variables – storage locations in memory for data Computer programs typically follow 3 steps 1. Input is received 2. Some process is performed on the input 3. Output is produced
11.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.2 Output, Input, and Variables (2 of 6) Input, Processing, and Output of a Pay Calculating program:
12.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.2 Output, Input, and Variables (3 of 6) IPO Chart: Describes the input, processing, and output of a program. Example: IPO Chart for the Pay Calculating Program Input Processing Output Number of hours worked Hourly pay rate Multiply the number of hours worked by the hourly pay rate. The result is the gross pay. Gross pay
13.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.2 Output, Input, and Variables (4 of 6) Display is the keyword to show output to the screen Sequence – lines execute in the order they appear String Literals – a sequence of characters Figure 2-7 The statements execute in order Figure 2-8 Output of Program 2-1
14.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.2 Output, Input, and Variables (5 of 6) Input is the keyword to take values from the user of the program It is usually stored in variables
15.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.2 Output, Input, and Variables (6 of 6) Programmers can define variable names following certain rules – Must be one word, no spaces – Generally, punctuation characters are avoided – Generally, the first character cannot be a number – Name a variable something that indicates what may be stored in it camelCase is popular naming convention
16.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.3 Variable Assignment & Calculations (1 of 2) Variable assignment does not always have to come from user input, it can also be set through an assignment statement Set price = 20
17.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.3 Variable Assignment & Calculations (2 of 2) Calculations are performed using math operators The expression is normally stored in variables Set sale = price – discount Table 2-1 Common math operators Symbol Operator Description + Addition Adds two numbers − Subtraction Subtracts one number from another Asterisk Multiplication Multiplies one number by another / Division Divides one number by another and gives the quotient MOD Modulus Divides one number by another and gives the remainder Caret Exponent Raises a number to a power ∗ ∧
18.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.4 Variable Declarations & Data Types (1 of 2) A variable declaration includes a variable’s name and a variable’s data type Data Type – defines the type of data you intend to store in a variable – Integer – stores only whole numbers – Real – stores whole or decimal numbers – String – any series of characters • Declare Real grossPay
19.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.4 Variable Declarations & Data Types (2 of 2) For safety and to avoid logic errors, variables should be initialized to 0 or some other value
20.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.5 Named Constants A named constant is a name that represents a value that cannot be changed – Makes programs more self explanatory – If a change to the value occurs, it only has to be modified in one place Constant Real INTEREST_RATE = 0.069
21.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.6 Hand Tracing a Program Hand tracing is a simple debugging process for locating hard to find errors in a program Involves creating a chart with a column for each variable, and a row for each line of code Figure 2-18 Program with the hand trace chart completed
22.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.7 Documenting a Program External documentation describes aspects of the program for the user, sometimes written by a technical writer Internal documentation explains how parts of the program works for the programmer, also known as comments // Comments are short notes placed in a program. // They explain how different parts of the // program work.
23.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.8 Designing Your First Program (1 of 5) Calculate the batting average for any player = ÷ Batting Average Hits Times at Bat Determine what is required for each phase of the program: 1. What must be read as input? 2. What will be done with the input? 3. What will be the output?
24.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.8 Designing Your First Program (2 of 5) 1. Input is received. – The number of hits – The number of times at bat 2. Some process is performed on the input. – Calculate the batting average – Divide the number of hits by the number of times at bat 3. Output is produced. – The player’s batting average
25.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.8 Designing Your First Program (3 of 5)
26.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.8 Designing Your First Program (4 of 5) Figure 2-20 Flowchart for program 2-15
27.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.8 Designing Your First Program (5 of 5) • Summary – Input ▪ Determine data needed for input ▪ Choose variables to store the input – Process ▪ Determine calculations to be performed ▪ Choose variables to store the calculations – Output ▪ Determine what output the program will display ▪ Usually the results of the program’s calculations
28.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java
29.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (1 of 11) • Setting up a Java Program public class Simple { public static void main(String[] args) { } } Class Name Class Header main Method
30.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (2 of 11) • Displaying Screen Output – System.out.println() Displays a line of output, then advances the output cursor to the next line. public class Output { public static void main(String[] args) { System.out.println("My major is Computer Science."); System.out.println("I plan to be a software developer."); System.out.println("Programming is fun!"); } } Program Output My major is Computer Science. I plan to be a software developer. Programming is fun!
31.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (3 of 11) • Displaying Screen Output – System.out.print() Displays output, but does not advance the output cursor to the next line. public class Output2 { public static void main(String[] args) { System.out.print("Programming"); System.out.print("is"); System.out.print("fun!"); } } Program Output Programmingisfun!
32.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (4 of 11) • Variable Declarations (see the rules for variable names on page 76 of your book) int speed; double distance; String name; Data Type What It Can Hold byte Integers in the range of –128 to +127 short Integers in the range of –32,768 to +32,767 int Integers in the range of –2,147,483,648 to +2,147,483,647 long Integers in the range of –9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 float Floating-point numbers in the range of ±3.4×10–38 to ±3.4×1038 , with 7 digits of accuracy double Floating-point numbers in the range of ±1.7×10–308 to ±1.7×10308, with 15 digits of accuracy String Strings of text.
33.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (4 of 11) • Variable Declarations (see the rules for variable names on page 76 of your book) int speed; double distance; String name; Data Type What It Can Hold byte Integers in the range of -128 to +128 short Integers in the range of -32,768 to +32,767 int Integers in the range of -2,147,483,648 to +2,147,483,647 long Integers in the range of –9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 float Floating-point numbers in the range of ±3.4 * 10-38 to ±3.4 * 1038, with 7 digits of accuracy double Floating-point numbers in the range of ±1.7 * 10-308 to ±1.7 * 10308, with 15 digits of accuracy String Strings of text
34.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (5 of 11) • Reading Keyboard Input (reading an integer) import java.util.Scanner; public class GetAge { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int age; System.out.println("What is your age?"); age = keyboard.nextInt(); System.out.println("Here is the value that you entered:"); System.out.println(age); } } Program Output What is your age? 24 [Enter] Here is the value that you entered: 24 Create a Scanner object Read an integer
35.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (6 of 11) • Reading Keyboard Input (reading a real number) import java.util.Scanner; public class GetAge { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); double temp; System.out.println("What is the temperature?"); temp = keyboard.nextDouble(); System.out.println("Here is the value that you entered:"); System.out.println(temp); } } Program Output What is the temperature? 74.5 [Enter] Here is the value that you entered: 74.5 Create a Scanner object Read a double
36.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (7 of 11) • Reading Keyboard Input (reading a string) import java.util.Scanner; public class GetAge { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); String name; System.out.println("What is your name?"); name = keyboard.nextLine(); System.out.println("Here is the value that you entered:"); System.out.println(name); } } Program Output What is your name? Jimmy [Enter] Here is the value that you entered: Jimmy Create a Scanner object Read a String
37.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (8 of 11) • Displaying Multiple Items with the + Operator Example: System.out.println("This is " + "one string."); This statement will display: This is one string. Example: number = 5; System.out.println("The value is " + number); This code will display: The value is 5
38.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (9 of 11) • Performing Calculations – Operators + Addition - Subtraction * Multiplication / Division % Modulus Examples: total = price + tax; sale = price - discount; population = population * 2; half = number / 2; leftOver = 17 % 3;
39.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (10 of 11) • Named constants – use the final key word in declarations: final double INTEREST_RATE = 0.069; This declares a double constant named INTEREST_RATE, set to the value 0.069.
40.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Java (11 of 11) • Documenting a program with comments // This is a line comment /* This is a multiline comment. */
41.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python
42.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python (1 of 8) • Displaying Screen Output – print() function Displays a line of output, then advances the output cursor to the next line. print('My major is Computer Science.'); print('I plan to be a software developer.'); print('Programming is fun!'); Program Output My major is Computer Science. I plan to be a software developer. Programming is fun!
43.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python (2 of 8) • You do not declare variables in Python. • Instead, you use an assignment statement to create a variable. • See the rules for variable names on page 81 of your book. age = 25 title = 'Vice President'
44.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python (3 of 8) • Pass multiple arguments to the print function, and Python will print each argument's value on the screen, separated by a space. age = 25 print('I am', age, 'years old.'); Program Output I am 25 years old.
45.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python (4 of 8) • Reading Keyboard Input (reading a string) first_name = input('Enter your first name: ') last_name = input('Enter your last name: ') print('Hello', first_name, last_name) Program Output Enter your first name: Vinny [Enter] Enter your last name: Brown [Enter] Hello Vinny Brown
46.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python (5 of 8) • Reading Keyboard Input (reading an integer) hours = int(input('How many hours did you work? ')) print('Here is the value that you entered:', hours) Program Output How many hours did you work? 40 [Enter] Here is the value that you entered: 40
47.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python (6 of 8) • Reading Keyboard Input (reading a real number) pay_rate = float(input('What is your hourly pay rate? ')) print('Here is the value that you entered:', pay_rate) Program Output What is your hourly pay rate? 20 [Enter] Here is the value that you entered: 20
48.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python (7 of 8) • Performing Calculations – Operators + Addition - Subtraction * Multiplication / Division % Modulus ** Exponent Examples: total = price + tax sale = price - discount population = population * 2 half = number / 2 leftOver = 17 % 3 result = 4**2
49.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: Python (8 of 8) • Documenting a program with comments # This is a comment
50.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++
51.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (1 of 11) • The typical C++ program contains the following code: #include <iostream> using namespace std; int main() { return 0; } You will write statements that appear in this area.
52.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (2 of 11) • Displaying Screen Output with the cout Statement – Begins with the word cout – followed by the << operator – followed by an item of data that is to be displayed. – The statement ends with a semicolon. #include <iostream> using namespace std; int main() { cout << "Hello world"; return 0; } Program Output Hello world
53.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (3 of 11) #include <iostream> using namespace std; int main() { cout << "Hello world"; return 0; } Program Output Hello world #include <iostream> using namespace std; int main() { cout << "Hello " << "world"; return 0; } Program Output Hello world #include <iostream> using namespace std; int main() { cout << "Hello "; cout << "world"; return 0; } Program Output Hello world #include <iostream> using namespace std; int main() { cout << "Hello" << endl; cout << "world" << endl; return 0; } Program Output Hello world
54.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (4 of 11) • Variable Declarations (see the rules for variable names on page 87 of your book) int speed; double distance; string name; Data Type What It Can Hold short Integers in the range of -32,768 to +32,767 int Integers in the range of -2,147,483,648 to +2,147,483,647 long Integers in the range of -2,147,483,648 to +2,147,483,647 float Floating-point numbers in the range of ±3.4 * 10-38 to ±3.4 * 1038, with 7 digits of accuracy double Floating-point numbers in the range of ±1.7 * 10-308 to ±1.7 * 10308, with 15 digits of accuracy char Can store integers in the range of -128 to +127. Typically used to store characters. string Strings of text bool Stores the values true or false
55.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (5 of 11) • Reading Keyboard Input (reading an integer) #include <iostream> using namespace std; int main() { int age; cout << "What is your age?" << endl; cin >> age; cout << "Here is the value that you entered:" << endl; cout << age; return 0; } Program Output What is your age? 24 [Enter] Here is the value that you entered: 24 Read a value into the age variable
56.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved #include <iostream> #include <string> using namespace std; int main() { string name; double payRate; int hours; cout << "Enter your first name." << endl; cin >> name; cout << "Enter your hourly pay rate." << endl; cin >> payRate; cout << "Enter the number of hours worked." << endl; cin >> hours; cout << "Here are the values that you entered:" << endl; cout << name << endl; cout << payRate << endl; cout << hours << endl; return 0; } Program Output Enter your first name. Connie [Enter] Enter your hourly pay rate. 55.25 [Enter] Enter the number of hours worked. 40 [Enter] Here are the values that you entered: Connie 55.25 40
57.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (7 of 11) • Using getline To Read String Input Containing Spaces #include <iostream> #include <string> using namespace std; int main() { string name; cout << "Please enter your name." << endl; getline(cin, name); cout << "Hello, " << name << endl; return 0; } Program Output Please enter your name. Kate Smith [Enter] Hello, Kate Smith
58.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (8 of 11) • Performing Calculations – Operators + Addition - Subtraction * Multiplication / Division % Modulus Examples: total = price + tax; sale = price - discount; population = population * 2; half = number / 2; leftOver = 17 % 3;
59.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (9 of 11) • Named constants – use the const key word in declarations: const double INTEREST_RATE = 0.069; This declares a double constant named INTEREST_RATE, set to the value 0.069.
60.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved 2.9 Focus on Languages: C++ (10 of 11) • Documenting a program with comments // This is a line comment /* This is a multiline comment. */
61.
Copyright © 2022,
2016, 2013, 2010 Pearson Education, Inc. All Rights Reserved Copyright
Download