CS1101X: Programming Methodology http:www.comp.nus.edu.sgcs1101x - PowerPoint PPT Presentation

About This Presentation
Title:

CS1101X: Programming Methodology http:www.comp.nus.edu.sgcs1101x

Description:

... 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. ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 7
Provided by: aaro3
Category:

less

Transcript and Presenter's Notes

Title: CS1101X: Programming Methodology http:www.comp.nus.edu.sgcs1101x


1
CS1101X Programming Methodology
http//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 gt 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 method
    solve(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
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) .
Write a Comment
User Comments (0)
About PowerShow.com