Level 1 - Inputs, outputs and structure 0 van 9 activiteiten opgelost
  1. Hello World Nog niet opgelost
  2. Carpet cost Nog niet opgelost
  3. Ball pit Nog niet opgelost
  4. Dice face 5 Nog niet opgelost
  5. Temperature converter Nog niet opgelost
  6. Fish tank volume Nog niet opgelost
  7. Microscopy Nog niet opgelost
  8. Circle properties Nog niet opgelost
  9. Energy bill calculator Nog niet opgelost
Volgende reeks Level 2 - Selections
Level 1 - Inputs, outputs and structure

Ball pit

Meld je aan om je oplossing in te dienen en feedback te krijgen.

// Ball pit program using System; class Submission { // ------------------------- // Subprograms // ------------------------- // Function to return the volume of the ball pit static double ball_pit_volume(double ball_pit_radius, double ball_pit_height) { double pi = 3.14; return pi * (ball_pit_radius * ball_pit_radius) * ball_pit_height; } // Function to return the volume of a ball static double ball_volume(double ball_radius) { double pi = 3.14; return (4.0 / 3.0) * pi * (ball_radius * ball_radius * ball_radius); } // ------------------------- // Main program // ------------------------- public static void Main(string[] args) { double ball_pit_radius = 1; // Meters double ball_pit_height = 0.2; // Meters double ball_radius = 0.05; // Meters double packing_density = 0.75; // Volume taken up by the balls int balls = (int)((ball_pit_volume(ball_pit_radius, ball_pit_height) / ball_volume(ball_radius)) * packing_density); Console.WriteLine("You need " + balls + " balls to fill the ball pit."); } }