id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

convertToHumanAge


/*
 * Chapter5Number23.java
 * 
 * Write a method that converts a dog’s age to the corresponding human age. 
 * Assume that a dog’s first year corresponds to a human age of 13, so 
 * convertToHumanAge(1) should return 13. After that, every three years in 
 * a dog’s life correspond to sixteen years in human life. The method returns 
 * the corresponding human age, rounded to the nearest integer.
 *
 * Copy code from convertToHumanAge(int dogAge) method below and replace
 * STUB line(s) with your code.
 *
 * @author YOUR NAME HERE
 */

public class Chapter5Number23
{
    // Precondition: dogAge > 0
    public static int convertToHumanAge(int dogAge)
    {
        return 0;   // STUB
    }
}

convertToHumanAge(1) → 13
convertToHumanAge(2) → 18
convertToHumanAge(3) → 24

...Save, Compile, Run (ctrl-enter)

public int convertToHumanAge(int dogAge) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy