Question: The method printYucaWeight ( ) has a double parameter. Define a second printYucaWeight ( ) method that has an integer parameter. The second method outputs

The method printYucaWeight() has a double parameter. Define a second printYucaWeight() method that has an integer parameter. The second method outputs the following in order, all on one line:
"Yuca weight as a whole number: "
the value of the integer parameter
" grams"
End with a newline.
Ex: If the input is 82.50082, then the output is:
Yuca weight to three decimal places: 82.500 grams
Yuca weight as a whole number: 82 grams import java.util.Scanner;
public class YucaWeight {
public static void printYucaWeight(double yucaWeight){
System.out.printf("Yuca weight to three decimal places: %.3f grams
", yucaWeight);
}
/* Your code goes here */
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
double yucaWeight1;
int yucaWeight2;
yucaWeight1= scnr.nextDouble();
yucaWeight2= scnr.nextInt();
printYucaWeight(yucaWeight1);
printYucaWeight(yucaWeight2);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!