Lecture C++ for everyone (2nd edition): Chapter 3 - Cay S. Horstmann

Chapter 3 - Decisions. one of the essential features of computer programs is their ability to make decisions. like a train that changes tracks depending on how the switches are set, a program can take different actions, depending on inputs and other circumstances. In this chapter, you will learn how to program simple and complex decisions. You will apply what you learn to the task of checking user input. | C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved Chapter Three: Decisions Slides by Evan Gallagher Chapter Goals To be able to implement decisions using if statements To learn how to compare integers, floating-point numbers, and strings To understand the Boolean data type To develop strategies for validating user input C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement Decision making (a necessary thing in non-trivial programs) C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement We aren’t lost! We just haven’t decided which way to go yet. C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement The if statement allows a program to carry out different actions depending on the nature of the data being processed C++ for Everyone by Cay Horstmann Copyright © 2012 by John . | C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved Chapter Three: Decisions Slides by Evan Gallagher Chapter Goals To be able to implement decisions using if statements To learn how to compare integers, floating-point numbers, and strings To understand the Boolean data type To develop strategies for validating user input C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement Decision making (a necessary thing in non-trivial programs) C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement We aren’t lost! We just haven’t decided which way to go yet. C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement The if statement allows a program to carry out different actions depending on the nature of the data being processed C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement The if statement is used to implement a decision. When a condition is fulfilled, one set of statements is executed. Otherwise, another set of statements is executed. C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement if it’s quicker to the candy mountain, else we go that way we’ll go that way C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement The thirteenth floor! C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement The thirteenth floor! It’s missing! C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement The thirteenth floor! It’s missing! OH NO !!! C++ for Everyone by Cay Horstmann Copyright © 2012 by John Wiley & Sons. All rights reserved The if Statement We must write the code to control the elevator. How .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.