Question

Let's create a void method and call it from main. Here is what to do. Write...

Let's create a void method and call it from main. Here is what to do.

  1. Write a void method that does not take any parameters called printFavorite. It should print your name and a favorite (subject, book, movie, etc) of yours.
  2. Call the method from main.

Run and test it.

For IDEs: Submit your .java file and a screenshot of the output of your code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class Favorite {

    public static void printFavorite() {
        System.out.println("Name: Critiano Ronaldo");
        System.out.println("Favorite Subject: Computer Science");
        System.out.println("Favorite Movie: Avengers");
    }

    public static void main(String[] args) {
        printFavorite();
    }
}

Add a comment
Know the answer?
Add Answer to:
Let's create a void method and call it from main. Here is what to do. Write...
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
  • Create a void method and call it from main. Here is what to do. Write a...

    Create a void method and call it from main. Here is what to do. Write a void method that does not take any parameters called printFavorite. It should print your name and a favorite (subject, book, movie, etc) of yours. Call the method from main. JAVA

  • In Java: Let's create a method that has parameters. Write a method, called returnHours that returns...

    In Java: Let's create a method that has parameters. Write a method, called returnHours that returns a string. Make the string from a string representing your name and a number representing the hours you spend sleeping, both are values that you pass in from the main. Create the variables to pass into the method call in main. Call the method and print the return value in main. Run and test it.

  • Now create the Book class that inherits from Product. Don't forget that each class must go...

    Now create the Book class that inherits from Product. Don't forget that each class must go in a file with a matching name, so put the Book class in Book.java. In the main method create a new Book object. Use setters to set the author, title and number Pages. Use the getters to print information about the book. Product Felda stock Number price Tethods getto accettera.. Book Food Fields title Pages Hethods etters and setters Fields expiration Year expiration Day...

  • Language = JAVA Create a new Java file called PhotoBillingYourLastName with a public static void main....

    Language = JAVA Create a new Java file called PhotoBillingYourLastName with a public static void main. Create three overloaded computePhotoBill() methods for Shutterfly. When computePhotoBill() receives a single double parameter, it represents the price of one photo book ordered. Add 6% tax and return the total due as a double. When computePhotoBill() received two parameters, they represent the price of a photo book and the quantity ordered (int). Multiply the two values, add 6% tax and return the total due....

  • Purpose: To learn how to create and use stand-alone class programs (classes withouta main method)...

    LE 7.2 Purpose: To learn how to create and use stand-alone class programs (classes withouta main method). When you take code out of the application class and put it in a class of its own, you make it reusable Prep Work: Chapter 7 Figure 7.6 shows you how an application class uses the services of a Java class in Figure 7.5. Although the code for LE 7.2 is different than the code in these figures, the concept is the same....

  • part 1(do not write on note book and before send program compile it) void testStruct01() this...

    part 1(do not write on note book and before send program compile it) void testStruct01() this function is called from main in main() call the function void test01() in the function void test01() 1. create a FootballTeam object    2. using 'cin', load the FootballTeam object   3. using 'cout', display (print) the FootballTeam object 4. output should look like the following         ********** AFC East ********** Home Team              XXXXXXXXXXXXXXXXXXXXXXXX Opponent team          XXXXXXXXXXXXXXXXXXXXXXXX Home Team score        XXXXXXXXXXXXXXXXXXXXXXXX Opponent team score   XXXXXXXXXXXXXXXXXXXXXXXX part...

  • create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines....

    create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method, check if the...

  • Project Objectives: To develop ability to write void and value returning methods and to call them...

    Project Objectives: To develop ability to write void and value returning methods and to call them -- Introduction: Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks (calling the methods) in the correct order. This also allows for efficiencies, since the method can...

  • Java 1. Create an application named NumbersDemo whose main() method holds two integer variables. Assign values...

    Java 1. Create an application named NumbersDemo whose main() method holds two integer variables. Assign values to the variables. In turn, pass each value to methods named displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared(). Create each method to perform the task its name implies. 2. Modify the NumbersDemo class to accept the values of the two integers from a user at the keyboard. This is the base code given: public class NumbersDemo { public static void main (String args[]) { // Write your...

  • Java : Please help me correct my code: create a single class (Program11.java) with a main...

    Java : Please help me correct my code: create a single class (Program11.java) with a main method and some auxiliary methods to input a 2-D array from a disk file, input some “transactions” to change the 2-D array and output the changed 2-D array to another file. Your main method will be minimal (see below). Most of the work will go on in your methods. In main, declare (but do not instantiate) 2-D array. Then call the three methods. The...

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