1 / 8

Early Program Design

Early Program Design. Intro to Computer Science CS1510 Dr. Sarah Diesburg. Problem #1 Calculating Olympic Prize Money. The USOC pays Olympic athletes who win medals the following in prize money: Gold $25,000 Silver $15,000 Bronze $10,000. Calculating Olympic Prize Money.

ltimmons
Download Presentation

Early Program Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Early Program Design Intro to Computer Science CS1510 Dr. Sarah Diesburg

  2. Problem #1Calculating Olympic Prize Money • The USOC pays Olympic athletes who win medals the following in prize money: • Gold $25,000 • Silver $15,000 • Bronze $10,000

  3. Calculating Olympic Prize Money • How much money did they pay? • Total (46/37/38) *** • Michael Phelps (5/1/0) • Katie Ledecky (4/1/0) • Simone Biles (4/0/1) *** Treats a team medal as one prize, not multiple prizes.

  4. Steps in solving this problem • Identify the prize money for each medal type (constant over each athlete). • Obtain the number of gold, silver, and bronze medals for the athlete (different for each athlete). • For each medal type, multiply the medal count with it’s prize amount. • Sum these three values to get total money won • Display total amount of money won

  5. We can do that !

  6. Calculating Olympic Prize Money (Summer Olympics) • The USOC pays • Gold $25,000 • Silver $15,000 • Bronze $10,000 • How much money did they pay? • Total (46/37/38) • Michael Phelps (5/1/0) • Katie Ledecky (4/1/0) • Simone Biles (4/0/1)

  7. Rules to Follow • Always have a header comment block with a Title, Author, Comment, and Deadline • See “Resources” page for Homework Submission Policy • Take care of line wrap • Good rule of thumb is not to have a line exceeding 60-70 characters • Can look at “Col” field at bottom of IDLE to see where you are at

  8. Rules to Follow • Put a comment on top of each chunk of code for the human • # Get the input for number of medals from user • Use a consistent style • camelCase • c_style_naming • Use constants • Every time you have a literal number (like 25000) • GOLD_PRIZE_AMOUNT=25000

More Related