Yorkville High School Computer Science Department
Yorkville High School Computer Science Department on Facebook  Yorkville High School Computer Science Department Twitter Feed  Yorkville High School Computer Science Department on Instagram

Yorkville High School Computer Science

ASSIGNMENTS: No Current Assignments

AP Computer Science :: Projects :: Pyramid Scheme

Rubric
Lesson
Due: Database Error

Problem

Write a method to calculate how many people would be necessary to raise a given amount of money in a pyramid scheme. Each person invites a given number of people until the last group of people are donating a dollar. Consider the example below where you are trying to raise $10 and each person invites 2 additional people:

           $10
     $5           $5
 $2      $2     $2     $2
$1 $1  $1 $1  $1 $1  $1  $1

In this example, it would take 15 people to raise $10 if each person invites 2 additional people. Notice that we are using integers so we will ignore issues with integer division.

Instructions

  1. Download this project to start.
  2. Complete the fundraise method so it returns the number of people needed to raise the desired amount of money.
  3. Don't worry about integer division. The method can stop when the last people are donating $1.
  4. RIght-click on the unit test when you are done to test your work. You will need to make your own unit test as well.
Yorkville High School Computer Science Department on Facebook Yorkville High School Computer Science Department Twitter Feed Yorkville High School Computer Science Department on Instagram