Skip Top Navigation Bar

Introduction to Type Conversions through Casting

Overview

In this lesson, students will learn how to manipulate data types through casting.

Learning Objectives

Skills

Student Outcomes

Students will be able to:

Duration: 1 class period

Resources

Warm-up / Motivate

In the Arithmetic Expressions and Assignment lesson plan, we learned that there are two different types of division.

Learn

Either as a group or on their own, have students complete tutorial: Learn: Introduction to Type Conversions with Casting

Apply

Have students use the Java Playground to write code to calculate a test grade when 60% of the score comes from a multiple choice section with 25 questions and 40% comes from a free response question with 3 parts. Each question on the multiple choice section is worth the same amount and each part of the free response exam is worth the same amount. Provide them with the following starter code:

   int mCQnumCorrect = 20; 
   double multipleChoicePart;
   int fRQCorrect = 2;
   double frqPart;
   int score;
   //add code to compute multipleChoicePart, frqPart, and score
   //use proper type casting to get the correct answer of 74

Next Lesson

Lesson Plan: Introduction to Input and Output