Class 14

# Class 14 - Click to edit Master subtitle style Alice to...

This preview shows pages 1–9. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 12/4/09 Click to edit Master subtitle style Alice to Java, Continued Matthew Hashim 10/8/2009 11 MGMT 290D 12/4/09 Goals for Today n Write some Java programs n Continue learning the basics of the Eclipse Integrated Development Environment (IDE) n Continue making the transition from Alice to Java MGMT 290D 22 MGMT 290D 12/4/09 A Second Java Program n Problem: how to determine relative value n Scenario 1 ¨ Regular size cereal costs \$2.90 per 12 ounces ¨ Economy size cereal costs \$4.00 per 15 ounces n Scenario 2 ¨ 60-gigabyte MP3 player costs \$150 ¨ 80-gigabyte model costs \$190 n Solution: compare items using unit prices n Goal: program should find the unit price of an item MGMT 290D 33 MGMT 290D 12/4/09 Designing the UnitPricer Program n Step 1: elements of user story built around unit price ¨ Query: “What is the price of the first item?” ¨ Read the first price from the keyboard ¨ Query “How many units are in the first item?” ¨ Read the number of units in the first item ¨ Perform the first four actions for the second item ¨ Compute and display the unit prices of the two items ¨ Use of a generic item broadens program’s application n Step 2: extract the objects from the noun phrases n Step 3: extract the methods from the verb phrases MGMT 290D 44 MGMT 290D 12/4/09 Designing the UnitPricer Program (continued) n Step 4: develop the UnitPricer algorithm n The algorithm is the blueprint for the program n Generalization: broadens application of a program n Generalization in the UnitPricer algorithm ¨ The use of “item” in place of cereal box and MP3 player ¨ “Item” is a generic term embracing a variety of objects MGMT 290D 55 MGMT 290D 12/4/09 Writing the UnitPricer Program n A summary of the steps ¨ Create a new Java project in Eclipse ¨ Create the UnitPricer class ¨ Implement the algorithm in main() MGMT 290D 66 MGMT 290D 12/4/09 Writing the UnitPricer Program (continued) MGMT 290D 77 MGMT 290D 12/4/09 Testing the UnitPricer Program n Conduct testing using easy-to-verify values...
View Full Document

{[ snackBarMessage ]}

### Page1 / 32

Class 14 - Click to edit Master subtitle style Alice to...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online