| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Java Exercises - Methods

Page history last edited by Steve Sweeney 10 years, 6 months ago

 

  1. Write a method printTriangle that has a char parameter c and an int parameter n.  The method should print a triangular pattern with the perimeter consisting of the character c and the interior (if there is one) consisting of blanks.  For example, the call printTriangle('*',5); should produce the following output:

    *

    **

    * *

    *  *

    *****

     

  2. Write a method called convertToGrade that returns a char value, and accepts an int parameter called mark.  The method should return the letter grade that corresponds to the value of mark (A, B, C, D, or F).  If the method receives an invalid value (outside of 0-100), it returns the character 'X'.

     

Comments (0)

You don't have permission to comment on this page.