Passer au contenu principal
SciNet
  • Accueil
  • Tous les cours
  • Calendrier
  • Certificats
  • SciNet
    Site principal Documentation my.SciNet
  • CCDB
  • Plus
Fermer
Activer/désactiver la saisie de recherche
Français
English Français
Vous êtes connecté anonymement
Connexion
SciNet
Accueil Tous les cours Calendrier Certificats SciNet Replier Déplier
Site principal Documentation my.SciNet
CCDB
Tout déplier Tout replier
  1. Tableau de bord
  2. PHY1610 - Winter 2023
  3. Assignment 1: C++

Assignment 1: C++

Conditions d’achèvement
Ouvert le : jeudi 12 janvier 2023, 00:00
À rendre : jeudi 19 janvier 2023, 23:59

For a perfectly elastic bouncy ball dropped from a height of \(h\) will bounce on the floor, the time between bounces (the "bounce time") would be given by

\[ t = \sqrt{\frac{8h}{g}} \]

where \(g\) is the gravitational acceleration on earth.

Now consider a set of \(n\) bouncy balls dropped from successively higher points, such that the \(i\) -th ball is dropped from a height 

\[ h_{i} = h_{avg} \frac{i}{2n} \]

where \(h_{avg}\) is the average drop point of the set, and \(i\) should run from 0 to \(n-1\) (true to the C++ style to start counting at zero). 

Note: there is a typo in the above formula, the 2 should be in the numerator for \(h_{avg}\) to be the average, but since it's already posted we'll leave the formula as is so everyone's assignment computes the same thing. 

Your assignment is to write a C++ program that can compute and output the bounce times of this set of bouncy balls.  

Your program:

  • should take the input parameters \(n\) and \(h_{avg}\) from keyboard  (you can use the value 9.81 m/s2 for the gravitational accelleration \(g\));
  • should write out (to screen or to a file, your choice) a set of lines with each line containing the drop-height (in meters), a space, and then the bounce time (in seconds);
  • should be a single file;
  • should have explanatory comments;
  • should contain, apart from the main function, at least 2 other functions
  • should not use global variables.

You should submit two files to the course website by midnight (ET) January 19th, 2023:

  1.  the file with your code
  2. a file containg the output for the case \(h_{avg}=100\), \(n=100\).

Both files should be plain text files (so no .doc, .docx, .rtf, .pdf, .odt, .ods, ... files) 


Contacter l’assistance du site
Vous êtes connecté anonymement (Connexion)
Résumé de conservation de données


All content on this website is made available under the Creative Commons Attribution 4.0 International licence, with the exception of all videos which are released under the Creative Commons Attribution-NoDerivatives 4.0 International licence.
Fourni par Moodle