1 / 6

CS1101X: Programming Methodology comp.nus.sg/~cs1101x/

CS1101X: Programming Methodology http://www.comp.nus.edu.sg/~cs1101x/. CS1101X: Practical tests. The following practical tests are for your own practice. They will not be graded. On the CourseMarker, look for “labPT1” and “labPT2”.

pigg
Télécharger la présentation

CS1101X: Programming Methodology comp.nus.sg/~cs1101x/

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. CS1101X: Programming Methodologyhttp://www.comp.nus.edu.sg/~cs1101x/

  2. CS1101X: Practical tests • The following practical tests are for your own practice. They will not be graded. • On the CourseMarker, look for “labPT1” and “labPT2”. • For each problem, aim to spend at most 45 minutes to complete the program: • Algorithm (15 minutes) • Codeing (10 minutes) • Testing (20 minutes) • Submit through CourseMarker and your leader may discuss the problem with you in class. • Deadline for submission is 28 September 2007, Friday, 2359hr.

  3. labPT1: Candles.java • Peter has n candles. He burns them one at a time and carefully collects all unburnt residual wax. Out of the residual wax of exactly k > 1 candles, he can roll out a new candle. • How many candles can Peter burn? • The input contains two integers giving the values of n and k. • The output should consist of just one integer giving the maximum number of candles that Peter can burn. • Write a modular program. There should be a methodsolve(int, int) .

  4. labPT1: Candles.java • Examples: • Enter n and k: 5 3No. of candles burned = 7 • Enter n and k: 100 10No. of candles burned = 111 • Enter n and k: 15 10No. of candles burned = 16

  5. New New labPT1: Candles.java Sample run: Enter n and k: 5 3 Number of candles burned = 7

  6. labPT2: Factors.java • Given a non-zero integer value, find its prime factor products. • Examples: • Enter value: 123123 = 1 * 3 * 41 • Enter value: 198198 = 1 * 2 * 3 * 3 * 11 • Enter value: -60-60 = -1 * 2 * 2 * 3 * 5 • Write a modular program. There should be a method factorise(int) .

More Related