Ask Question

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

+2
Answers (1)
  1. 27 June, 13:06
    0
    public class walk {

    //create the function

    public static void takeAwalk (int spare_Minute) {

    //check the condition and print if match

    if (spare_Minute>=60) {

    System. out. println ("Store");

    }else if (spare_Minute>=10) {

    System. out. println ("Block");

    }else {

    System. out. println ("Nowhere");

    }

    public static void main (String[] args) {

    //call the function

    takeAwalk (60);

    }

    }

    Explanation:

    Create the class and define the function takeAwalk which takes one parameter of integer type and the function return type is void. It means the function does not return any value.

    In the function, take the continuous if-else statement.

    syntax:

    if (condition) {

    statement;

    }else if (condition) {

    statement;

    }else{

    statement;

    }

    it takes the condition, if the condition is true then execute the statement otherwise program move to the else if () part. if this is also false then the program moves to the else part.

    create the main function for testing the program and call the function.

    suppose the value pass is 60.

    then, program control moves to the function definition and start executing.

    if-else statement checks the condition, 60 > = 60 condition match and the program print the message "Store".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers