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

Write these in Java. 1. Write a method or function that accepts an argument for

ID: 3662589 • Letter: W

Question

Write these in Java.

1. Write a method or function that accepts an argument for the age of an individual and returns the year that person was born.

2. Write a method of function that accepts an integer argument. The method should use “if-else” statements to determine if the integer is between 45 and 55.

3. Write a method or function that accepts an argument for a person’s name. The method should loop through the number of characters in the name sending each character to the screen each on a separate line.

Explanation / Answer

1.


import java.util.Calendar;


public class Test {
   
     

public static   void   getYearBorn(int age)     
   
     {
        
       int y = Calendar.getInstance().get(Calendar.YEAR);
       int a=y-age;
       System.out.println(a);
     }
      

   public static void main(String[] args)
   {
       getYearBorn(22);
   }
   }

2. public static   void   inBetween(int n)     
   
     {
        
       if(n>45 && n<55)
       System.out.println("yes");
       else
           System.out.println("no");
     }

3.

public static   void   inChars(String s)     
   
     {
     
for (int i = 0; i < s.length(); i++) {
    System.out.println(s.charAt(i));
}
     }