Question

java Write a method takeAWalk which will take an argument saying how many spare minutes you...

java

Write a method takeAWalk which will take an argument saying how many spare minutes you have for your walk (a whole number), and will print out where you will go using System.out.println. If you have at least 60 minutes for your walk, you will go to the store: print "Store". Otherwise, if you have at least 10 minutes, you will walk around the block: print "Block". Otherwise, print "Nowhere". The method does not return any value.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
//TestCode.java
public class TestCode {
    public static void takeAWalk(int n){
        if(n>=60){
            System.out.println("Store");
        }
        else if(n>=10){
            System.out.println("Block");
        }
        else{
            System.out.println("Nowhere");
        }
    }

    public static void main(String[] args){
        // Testing
        takeAWalk(45);
    }
}

Block

Add a comment
Know the answer?
Add Answer to:
java Write a method takeAWalk which will take an argument saying how many spare minutes you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • java ASAP Assume that you have tracked daily minutes of you work out for a week....

    java ASAP Assume that you have tracked daily minutes of you work out for a week. Save the following data into a text file in a notepad. 50 10 36 11 47 30 Write a java program that reads the minutes for a week from the text file that you created. Read the minutes from the input file into the array in one execution of the program.write a java method to find out the maximum and minimum values. Your program...

  • We need to write a method that, given a key as an argument, returns the next...

    We need to write a method that, given a key as an argument, returns the next in order key found in the binary search tree. If the key given as an argument is not found, the method should still return the next in order key. If the binary tree is empty or all the stored keys are smaller than the argument, then the return value should be empty. For example, using a collection of {10,13,52,67,68,83} stored in the binary search...

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

    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....

  • To be written in JAVA We want you to write a Java class named Character WithStatus...

    To be written in JAVA We want you to write a Java class named Character WithStatus that can be used to keep track of random game effects status on a role playing game character. The following requirements specify what fields you are expected to implement in your class: - A String data field named name to store the character's name - An int data field named health to store the character's health point; at zero they are dead. - An...

  • How would I code this method in Java using a scanner? Begin by asking how many...

    How would I code this method in Java using a scanner? Begin by asking how many spaces the row should be with a prompt using System.out.print like the following, with 40 as the maximally allowed number of spaces: (user input shown bold) Please enter the number of spaces for the game (1-40): eight To do this, use the promptNumberReadLine method that you will write, described on the back page. If the user does not type a number in the correct...

  • Write a complete JAVA program, including comments (worth 2 pts -- include a good comment at...

    Write a complete JAVA program, including comments (worth 2 pts -- include a good comment at the top and at least one more good comment later in the program), to process data for the registrar as follows: NOTE: Include prompts. Send all output to the screen. 1. Read in the id number of a student, the number of credits the student has, and the student’s grade point average (this is a number like 3.25). Print the original data right after...

  • package week_3; /** Write a method called countUppercase that takes a String array argument. You can...

    package week_3; /** Write a method called countUppercase that takes a String array argument. You can assume that every element in the array is a one-letter String, for example String[] test = { "a", "B", "c", "D", "e"}; This method will count the number of uppercase letters from the set A through Z in the array, and return that number. So for the example array above, your method will return 2. You will need to use some Java library methods....

  • Write a new program called TrickOr Treat that will do the following 1. In a while...

    Write a new program called TrickOr Treat that will do the following 1. In a while loop, say "Trick or Treat!" and allow the user to type in the name of a candy and store it in an ArrayList. Once the user types "Trick", then the loop should stop. Then, print out the total number of candies on the screen. (See example below) [1 points] 2. Write a method called countSnickers that will take an ArrayList of candy as an...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • Problem 1 1. In the src → edu.neiu.p2 → problem1 directory, create a Java class called...

    Problem 1 1. In the src → edu.neiu.p2 → problem1 directory, create a Java class called HW4P1 and add the following: • The main method. Leave the main method empty for now. • Create a method named xyzPeriod that takes a String as a parameter and returns a boolean. • Return true if the String parameter contains the sequential characters xyz, and false otherwise. However, a period is never allowed to immediately precede (i.e. come before) the sequential characters xyz....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT