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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Java Exercises - Methods

Page history last edited by Steve Sweeney 14 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.