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

1) Methods with 1+ parameter- 0 returns (careful with parameter var Example: A m

ID: 644096 • Letter: 1

Question



1) Methods with 1+ parameter- 0 returns (careful with parameter var Example: A method that prints your first and last name (receive names as parameter) Public static void printName(){ //receives 2 Strings for names // join names together seperated by a space and print name a) A method that prints a title to a song and the 1st 3 lines of lyrics (receive name & lyrics) b) A method that adds two numbers together and prints the result (receive numbers) c) A method that turns feet and inches into just inches (receives feet & inches) 2) Methods with 1+ parameter, 1 returns (careful with parameter var tvoes1; Example: A method that received your first and last name and returns your full name (receive names) Public static String returnName(String fName, String IName){ //receive first and last name as String parameters // joins first and last name with space between and returns the resulting string a) A method that receives 2 numbers and returns the total (receive numbers) b) A method that returns fahrenheit when given celcius (receive celcius as parameter)

Explanation / Answer

1.

public static void printName(String first, String last){
       String name = first + " " + last;
       System.out.println(name);
   }

(a)

// Sorry, I didn't understand the question I guess. How do we pass the lyrics as parameter? File?

(b)

public static void addNumbers(int a, int b){
       int result = a + b;
       System.out.println(result);
   }

(c)

public static void feetInches(int feet, int inches){
       int inch = feet * 12 + inches;
       System.out.println(inches);
   }

2.

public static String returnName(String first, String last){
       String name = first + " " + last;
       return name;
   }

(a)

public static int returnSumNumbers(int a, int b){
       int result = a + b;
       return result;
   }

(b)

public static double ctof(double c){
       return c * 1.8 + 32.0;
   }