Programming Exercises

   


1:

Sometimes, the number of cars passing a certain point on a highway needs to be counted. Suppose a person needs to count the cars passing by every hour for one full week. Write a program that can assist this person in storing, retrieving, and analyzing this information. In particular the program must be able to

  • Store car count entries on an hourly basis for 24 hours a day and for 7 days.

  • Let the user enter a specific count by specifying the day, hour, and count.

  • Let the user retrieve a specific count by specifying the day and hour.

  • Calculate and display the total number of counts for the whole week.

  • Determine the number of hours it takes before a given number of cars have passed by. For example, if the first five hours contain the following counts 30, 40, 10, 50, and 100, it takes 3 hours to reach 75 or more cars, and 5 hours to reach 226 or more cars.

    Notice that the user expects the day indexes to be 1 7 (this requires an adjustment to the zero-base array access) and the hour indexes to be 0 23.

2:

Write a program containing a three-dimensional array of type int called numbers with the following dimensions: 5, 10, and 8. The user must be able to enter and retrieve individual values from this array by entering a chosen set of indexes. Further, the program must be able to calculate the sum of all numbers stored in all elements of the numbers array.


   


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net