• 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! Dokkio, a new product from the PBworks team, integrates and organizes your Drive, Dropbox, Box, Slack and Gmail files. Sign up for free.


Java Exercises - Methods

Page history last edited by Steve Sweeney 10 years, 1 month 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.