Decisions

Decisions

  • Author: Dr. N. Bashias

  • Department: Computer Science, University of Dayton

Contents Overview
  • Flow of Control

  • The If Statement

  • Comparison of Integers, Floating-Point Numbers, and Strings

  • If-Else Statements

  • Handling Problems: Leap Years and Bookstore Sales

Flow of Control
  • Statements execute sequentially, modified by decision statements based on conditions.

The If Statement
  • Syntax: if (condition) { // statements }

  • Executes statements if true; skips if false.

Compound Statements
  • Use braces {} for multiple statements together.

Comparisons
  • Various relational operators for comparing different data types.

  • Precision issues may arise for floating-point comparisons.

Input Validation
  • Validate inputs with conditions; actions include terminating execution or error messaging.

Logical Operators
  • Combine Boolean expressions with logical operators and display truth tables.

Programming Examples
  • Detailed examples for calculating dew point and determining leap years using structured logic and methods.