Class 16

# Class 16 - Alice to Java, Continued 1 Goals for Today n n n...

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

Alice to Java, Continued 1

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

View Full Document
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 29000-002 2
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 29000-002 3

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

View Full Document
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 29000-002 4
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 29000-002 5

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

View Full Document
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 29000-002 6
Writing the UnitPricer Program (continued) MGMT 29000-002 7

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

View Full Document
Testing the UnitPricer Program n Conduct testing using easy-to-verify values n The printf() message revisited ¨ Begin format-string with %n to advance cursor one line
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/04/2012 for the course MGMT 290 taught by Professor Staff during the Fall '08 term at Purdue.

### Page1 / 32

Class 16 - Alice to Java, Continued 1 Goals for Today n n n...

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

View Full Document
Ask a homework question - tutors are online