Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In the space below, write a method that calculates and returns the number of hou

ID: 3592234 • Letter: I

Question

In the space below, write a method that calculates and returns the number of hours of sleep realized per night according to the table below. ( Just a guess for the data !)

Number of hours of sleep realized per night

Under 25

25 or over

public double getHoursOfSleep( int age, char gender )

Integer division for quotients and remainders

Implement the function to compute the smallest number of feet greater than or equal the parameter given in inches

public   int   feetNeeded( int inches )

{

}

Number of hours of sleep realized per night

male female

Under 25

5 6

25 or over

8 7

public double getHoursOfSleep( int age, char gender )

Explanation / Answer

Please find my implementation.

public class App {

   public double getHoursOfSleep( int age, char gender ) {

      

       if(age < 25) {

           if(gender == 'm' || gender == 'M')

               return 5;

           else

               return 6;

       }else{

           if(gender == 'm' || gender == 'M')

               return 8;

           else

               return 7;

       }

   }

  

   public static int feetNeeded( int inches )

   {

       double feet = inches / 12.0;

      

       if(feet - (int)feet == 0)

           return (int)feet;

       else

           return (int)(feet+1);

   }

  

   public static void main(String[] args) {

      

       System.out.println(feetNeeded(37));

   }

}