Write a java program calls the following methods: printStars(): Takes an int (n) as parameter and prints n stars (*) using for loop. Multiples(): Takes an int (n) as parameter and  prints first 10 multiples n in a single line using for loop. hasAnEvenDigit: Takes an int (n) as parameter and returns whether n has at least one digit whose value is even. Return true if the number has at least one even digit else false if none of the digits are even. For example, the call hasAnEvenDigit(33267) should return true and hasAnEvenDigit(7591) should return false.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 14E
icon
Related questions
Question
100%

Instructions

  • Complete the lab using “for loop”.
  • Do not write the code in multiple programs. All the 3 methods should be written in 1 program.

 

  1. Write a java program calls the following methods:
    1. printStars(): Takes an int (n) as parameter and prints n stars (*) using for loop.
    2. Multiples(): Takes an int (n) as parameter and  prints first 10 multiples n in a single line using for loop.
    3. hasAnEvenDigit: Takes an int (n) as parameter and returns whether n has at least one digit whose value is even. Return true if the number has at least one even digit else false if none of the digits are even. For example, the call hasAnEvenDigit(33267) should return true and hasAnEvenDigit(7591) should return false.

[Hint: n%10 returns the last digit and n/10 returns everything except the last digit]

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr