Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for...
Next
In Process
ptntuto
  • 7
ptntuto
Asked: April 11, 20222022-04-11T18:36:39+00:00 2022-04-11T18:36:39+00:00In: Computer-Science

Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for…

  • 7

. Advertisement .

..3..

. Advertisement .

..4..

Answer in JAVA

1. Complete the method definition to output the hours given minutes. Output for sample program:

3.5
import java.util.Scanner; public class HourToMinConv {    public static void outputMinutesAsHours(double origMinutes) {

      /* Your solution goes here */

   }

   public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       double minutes;

      minutes = scnr.nextDouble();

      outputMinutesAsHours(minutes); // Will be run with 210.0, 3600.0, and 0.0.       System.out.println("");    } }

2. Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ‘ and ” shorthand. End with a newline. Ex: printFeetInchShort(5, 8) prints:

5' 8"

Hint: Use ” to print a double quote.

import java.util.Scanner;

public class HeightPrinter {

   /* Your solution goes here */

   public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       int userFeet;       int userInches;

      userFeet = scnr.nextInt();       userInches = scnr.nextInt();

      printFeetInchShort(userFeet, userInches); // Will be run with (5, 8), then (4, 11)    } }

3. Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print “Too few.”. If more than 4, print “Too many.”. Else, print “N: Lather and rinse.” numCycles 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 ShampooMethod {

   /* Your solution goes here */

   public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       int userCycles;

      userCycles = scnr.nextInt();       printShampooInstructions(userCycles);    } }
  • 1 1 Answer
  • 1k Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Alexander Taylor
    2022-04-12T00:14:56+00:00Added an answer on April 12, 2022 at 12:14 am

    1.

    import java.util.Scanner;
    
    public class HourToMinConv {
    public static void outputMinutesAsHours(double origMinutes) {
    System.out.print(origMinutes / 60);
    }
    
    public static void main(String[] args) {
    Scanner scnr = new Scanner(System.in);
    double minutes;
    
    minutes = scnr.nextDouble();
    
    outputMinutesAsHours(minutes); // Will be run with 210.0, 3600.0, and 0.0.
    System.out.println("");
    }
    }
    210.0
    3.5
    
    Process finished with exit code 0

    2.

    import java.util.Scanner;
    
    public class HeightPrinter {
    
    public static void printFeetInchShort(int numFeet, int numInches) {
    System.out.println(numFeet + "' " + numInches + """);
    }
    
    public static void main(String[] args) {
    Scanner scnr = new Scanner(System.in);
    int userFeet;
    int userInches;
    
    userFeet = scnr.nextInt();
    userInches = scnr.nextInt();
    
    printFeetInchShort(userFeet, userInches); // Will be run with (5, 8), then (4, 11)
    }
    }

    Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for...

    3:

    import java.util.Scanner;
    
    public class ShampooMethod {
    
        static void printShampooInstructions(int numCycles) {
            if (numCycles < 1) {
                System.out.println("Too few..");
            } else if (numCycles > 4) {
                System.out.println("Too many..");
            } else {
                for (int i = 1; i <= numCycles; ++i) {
                    System.out.println(i + ": Lather and rinse.");
                }
                System.out.println("Done.");
            }
        }
    
        public static void main(String[] args) {
            Scanner scnr = new Scanner(System.in);
            int userCycles;
    
            userCycles = scnr.nextInt();
            printShampooInstructions(userCycles);
        }
    }

    Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for...

    • 20
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.