Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for sample
Question:
1.
Complete the method definition to output the hours given minutes. Output for sample program:
3.5
import java.util. Scanner;
public class Hour To Min Conv {
public static void output Minutes As Hours(double orig Minutes) {
/* Your solution goes here */
}
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
double minutes;
minutes = scnr.nextDouble();
output Minutes As Hours(minutes); // Will be run with 210.0, 3600.0, and 0.0.
System.out.println("");
}
}
2.
Define a method print Feet Inch Short, with int parameters num Feet and numInches, that prints using ' and " shorthand. End with a newline. Ex: print Feet Inch Short(5, 8) prints:
5' 8"
Hint: Use " to print a double quote.
import java.util. Scanner;
public class Height Printer {
/* Your solution goes here */
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
int user Feet;
int user Inches;
user Feet = scnr.nextInt();
user Inches = scnr.nextInt();
print Feet Inch Short(user Feet, user Inches); // Will be run with (5, 8), then (4, 11)
}
}
3.
Write a method print Shampoo Instructions(), with int parameter num Cycles, and void return type. If num Cycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." num Cycles times, where N is the cycle number, followed by "Done.". End with a newline. Example output with input 2:
1: Lather and rinse.
2: Lather and rinse.
Done.
Hint: Declare and use a loop variable.
import java.util. Scanner;
public class Shampoo Method {
/* Your solution goes here */
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
int userCycles;
user Cycles = scnr. nextInt();
print Shampoo Instructions(user Cycles);
}
}
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser