CSC 120

Week 4


Reading Assignment:

Finish reading Chapter 3

Here are some of the programs we studied in class: Block.java OddEven_if.java ManyElseIf.java For.java Switch.java BreakContinue.java MultiplicationTable.java Average.java PrintMin.java Valentine_2.java


Lab/Homework Assignment:

  1. Modify the MultiplicationTable.java code above so that it asks the reader to specify the size of the table (between 2 and 13). Make sure that the entries line up nicely. To accomplish this, use System.out.printf(......) for formatted print. Learn about how to printf (see page 26 of textbook) or info printf Hint: use System.out.printf("%4d", N * rowNumber );

  2. Study the pattern below and write a program that produces the table.
      
        A BOARD OF DIGITS     
      
      1  0  0  0  0  0  0  0  0
      2  2  0  0  0  0  0  0  0
      3  3  3  0  0  0  0  0  0
      4  4  4  4  0  0  0  0  0
      5  5  5  5  5  0  0  0  0
      6  6  6  6  6  6  0  0  0
      7  7  7  7  7  7  7  0  0
      8  8  8  8  8  8  8  8  0
      9  9  9  9  9  9  9  9  9
           
    Can you find the pattern?
    

  3. Write a program that asks the user to enter a numeric grade (an integer between 0 and 100) and returns a letter grade corresponding to a given numerical grade on a grading scale:
    90 or above gets an A
    80 to 89  gets a B
    65 to 79 gets a C
    50 to 64 gets a D
    anything else gets an F
    
    Make sure to check the input: if the number is negative or greater then 100, issue a message and ask the user to re-enter the number.