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

Directions: Given the following problem descriptions, write appropriate method c

ID: 3817773 • Letter: D

Question

Directions: Given the following problem descriptions, write appropriate method call and method definitions for each problem(In Java).

A) Write a method call and a method definition for a method named getName that will prompt for the user’s first name and return it to the calling method where it will be stored in a variable named firstName.

B) Write a method call and a method definition for a method named tenTimes that will accept a double argument, and return a double value that is ten times the value of the argument. The calling method will printout the returned value.

Explanation / Answer

A)

Method defination:-

String getName();

Method call:-

String getName(){
        Scanner scanner = new Scanner(System.in);
        System.out.print("Please enter your first name ");
        String name = scanner.next();
        return name;
      
    }

B.

Method defination:-

double tenTimes(double x);

Method call:-

    double tenTimes(double x){
        return (x*(10.0));
      
    }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote