Important Notice:

Practice-It will be discontinued as of November 1st, 2024. After this date, the website will remain online for a transitional period, but login will be restricted to University of Washington NetID authentication. This marks the next phase towards the platform's full retirement. Thank you for your use and support of the application over the years.

If you are looking for an alternative, a similar tool, CodeStepByStep, was developed independently by the original author of Practice-It, and is available at codestepbystep.com**

logo Practice-It logo

graduation

Language/Type: Java method basics return
Author: Marty Stepp (on 2010/12/28)

Write a method named graduation that accepts a student's GPA, total credit count, and honors credit count as parameters, and returns a String representing that student's graduation status. The total credit count already includes the honors credits. The graduation status to return is determined by the following rules:

  • Students must have completed at least 180 credits with a GPA of at least 2.0 to graduate. A student who does not meet both of these constraints should receive a return value of "not graduating".
  • Students who do have enough credits to graduate and sufficiently high GPAs will receive one of four return values depending on the GPA and number of honors credits:
    • All students with GPAs between 2.0 and 3.6 receive a return value of "graduating".
    • Students with fewer than 15 honors credits receive a return of "cum laude" if their GPA is at least 3.6 but less than 3.8, and a return of "magna cum laude" if their GPA is at least 3.8.
    • Students with 15 or more honors credits receive a return of "magna cum laude" if their GPA is at least 3.6 but less than 3.8, and a return of "summa cum laude" if their GPA is at least 3.8.

Here are some example calls to the method and their resulting return values:

Call Value Returned
graduation(3.87, 178, 16)
graduation(1.5, 199, 30)
graduation(2.7, 380, 50)
graduation(3.62, 200, 20)
graduation(3.93, 185, 0)
graduation(3.85, 190, 15)
"not graduating"
"not graduating"
"graduating"
"magna cum laude"
"magna cum laude"
"summa cum laude"

You may assume that the GPA will be between 0.0 and 4.0 and that both credit counts will be non-negative integers.

Type your solution here:


This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.