Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Programming, 3e Concepts and Techniques Chapter 3 Section 62 – Manipulating Data Using Methods – Day 1.

Similar presentations


Presentation on theme: "Java Programming, 3e Concepts and Techniques Chapter 3 Section 62 – Manipulating Data Using Methods – Day 1."— Presentation transcript:

1 Java Programming, 3e Concepts and Techniques Chapter 3 Section 62 – Manipulating Data Using Methods – Day 1

2 Chapter 3: Manipulating Data Using Methods 2 Objectives Understand the different ways to get input in Java (console application in a command prompt window, console application with dialog boxes and applets) Identify, declare, and use primitive data types Set up a new project for calculating body mass index

3 Chapter 3: Manipulating Data Using Methods 3 Introduction Data are collections of raw facts or figures A program performs operations on input data to output information Input data can come from a variety of sources –The program itself –Users of the program –External files

4 Chapter 3: Manipulating Data Using Methods 4 The Body Mass Index Calculator An interactive program –Accepts the weight and height from the user –Calculates the BMI to gauge total body fat –Displays the result Three versions –Input/Output using the command prompt –Input/Output using dialog boxes –Web environments use an applet interface

5 Chapter 3: Manipulating Data Using Methods 5 (b) console application using dialog boxes (a) console application in a command prompt window (c) applet

6 Chapter 3: Manipulating Data Using Methods 6

7 7 Problem Analysis Convert user input to metric measurements Calculate the BMI Display the result

8 Chapter 3: Manipulating Data Using Methods 8 Design the Solution Design the three kinds of user interfaces with storyboards Design the logic of the program –Use pseudocode for sequential flow for all programs –Use an event diagram for the applet Validate the design –Compare the program design with the original requirements

9 Chapter 3: Manipulating Data Using Methods 9 Storyboards

10 Chapter 3: Manipulating Data Using Methods 10

11 Chapter 3: Manipulating Data Using Methods 11 Coding the Program Import the java.io package –Provides classes to support system input and output Add a throws IOException clause to the method header –Warns the compiler that the possibility of input or output errors exists –Gives the program the opportunity to handle input or output errors during run-time without aborting

12 Chapter 3: Manipulating Data Using Methods 12 Set up a new project in NetBeans Open NetBeans Create a new project called BodyMassCalculator Choose Java>Java Application Set the Main Class to bodymasscalculator.BodyMass

13 Chapter 3: Manipulating Data Using Methods 13 Coding the Program Add the java.io.* library Add “throws IOException”

14 Chapter 3: Manipulating Data Using Methods 14 Storing Data Java is a strongly typed language –Variables must be declared with a data type –Variable locations can hold only that data type Java has two categories of data types –Primitive data types hold single data items Integers, characters, floating point, and booleans are primitive types –Reference data types hold a value that refers to the location of the data All Objects and arrays are reference types

15 Chapter 3: Manipulating Data Using Methods 15

16 Chapter 3: Manipulating Data Using Methods 16 Declaring Variables

17 Chapter 3: Manipulating Data Using Methods 17 Declare the Variables You Need Add variable declarations

18 Chapter 3: Manipulating Data Using Methods 18 Summary Variables are simply places to store information –Variables can only store one type of data There are different ways to get input from the user

19 Chapter 3: Manipulating Data Using Methods 19 Rest of Today Make sure you have created the BodyMassCalculator class and added the variables you will need.


Download ppt "Java Programming, 3e Concepts and Techniques Chapter 3 Section 62 – Manipulating Data Using Methods – Day 1."

Similar presentations


Ads by Google