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: 3818729 • Letter: D

Question

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

A) Write a method call and a method definition for a method named showValue that will print out the value of an integer variable named amount. The amount variable will be a local variable declared in the calling method.

B) Write a method call and a method definition for a method named showProduct that will print out the result of the multiplication of two double values. The product should be printed out with 2 decimal positions. The two double values will be defined in the calling method as two variables, nbr1 and nbr2.

C) Write a method call and a method definition for a method named showValues that will print out the values of the following three variables that are declared in the calling method. The float value should be printed out with 2 decimal positions.

char answer = ‘Y’;

double amount = 36.546312;

int count = 5;

Explanation / Answer

A)Method Definition:
void showValue(int amount)
{
System.out.println("Amount= "+amount);
}

public static void main(String [] args)
{
showValue(100);
}

B)Method Definition:
void showProduct(double b1, double b2)
{
double r1;
r1=b1*b2;

System.out.println("product= "+round(r1,2));
}

public static void main(String [] args)
{
showProduct(100.999,77.876);
}

C) Method Definition:
Void showValues(char ans,double amt, int count)
{
System.out.println("Answer= "+and);
System.out.println("amount= "+round(amt,2));
System.out.println("Count= "+count);
}

public static void main(String [] args)
{
showValues('Y',36.546312,5);
}

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