Module 5: Numbers and Dates

CMPS 162: Introduction to Programming

Introduction

Besides strings, numbers are the other data type that are frequently used in programs. Anything that involves calculations, from basic arithmetic to advanced scientific computations, operates on numbers as the basic building block. Example functionality that we will cover involves rounding numbers and generating random numbers, which may not sound very useful but it allows our programs to behave in a nondeterministic way (e.g., to implement shuffling a deck of cards). We will also look at how we can convert the textual representation of a number (in a string) to an actual number and vice versa. Finally, being able to retrieve the current date and time and making changes, e.g., move to next week, allows us to implement calendaring and related functionality.

Module Objectives

  • Apply rounding numbers
  • Apply generating random numbers
  • Describe converting strings to integers and decimals
  • Describe converting strings to numbers, numbers to strings
  • Illustrate controlling the length of decimals
  • Explain getting the current date and time
  • Show extracting parts of the date and time
  • Illustrate specifying a date and time
  • Explain changing elements of a date and time

Learning Resources

  • Module 5 Readings: Chapters 26 thru 34 from Myers

Learning Activities

  • Module 5 Assignment: Interactive Coding Exercises 26 thru 34

For Further Study

  • None

Leave A Reply

Your email address will not be published. Required fields are marked *