SE 1011 Practice Problems

The following are not assigned, but doing these exercises will help you prepare for the exam. Certainly feel free to ask your instructor for help with the problems if you run into roadblocks.

Write programs to do the following. In each case, user input is in bold text.

  1. Ch 3: Prompt for a number of minutes, and print hours and minutes:
    Enter number of minutes: 280
    4 hours, 40 minutes
    
    More samples.

  2. Ch 3: Prompt for first and last name and print number of characters, formatted as shown:
    Enter first and last names: Tom Riddle
    
        Last,First: Riddle,Tom
    
        Letters:    9
    
    More samples.

  3. Ch 4: Prompt for number of minutes between 0 and 1440 (inclusive), print time in hh:mm format with a leading 0 in front of the minutes:
    Enter number of minutes: 280
    Time: 4:40
    
    More samples.

  4. Ch 4: Prompt for a name and print all the letters of that name, one per line. Use .charAt to get the letters, remembering that .charAt(0) returns the first letter. If len is the length of the name, .charAt(len - 1) returns the last letter.
    Enter your name: Tricia
    Letters:
      1. T
      2. r
      3. i
      4. c
      5. i
      6. a
    
    More samples.

  5. Ch 4: Prompt for an integer and print all values divide the number evenly. Use % to test if a number divides another: 21 % 7 is 0, so we know that 7 divides 21.
    Enter an integer: 12
    Divisors: 1 2 3 4 6 12
    
    More samples.