write a program that will call 2 methods from main but will also ask the user a ques 5155608

Write a program that will call 2 methods from main, but will also ask the user a question between the 2 method calls, and will pass a value to the second method call:

  1.   displayLoveMessage()   
  2.   Get a number between 20 and 30, inclusive, from the user.

  Validate that the number entered is indeed in the valid range.

  1.   Once you have a valid number, pass it the method called sumOfNumbers(validNum)

Task 1:  

In the displayLoveMessage() method,    

  1. Ask user for their first name
  2. Convert their first name to upper case
  3. Ask user for their significant other’s first name
  4. Convert their significant other’s  first name to upper case
  5. Get the first initial of each name (hint:  Use charAt )
  6. Concatenate the first initial of user’s name with “ loves “ and the first initial of significant other.
  7. For example, when the user enters “Mary” and then “John” the method will sout “M loves J”

Task 2:

In main, after calling displayLoveMessage() method, ask the user for a number between 20 and 30, inclusive, and keep asking the user that question until a valid number is entered by the user.

Task 3:

In the sumOfNumbers(int validNum) method,

  1. Use the validNum as the limit of a loop that starts at 1 and loops until validNum, inclusive, printing only the numbers that are divisible by 5.
  2. For example if the parameter is 20, then the following numbers would be printed, because they range from 1 to 20, and are divisible by 5:
    5 10 15 20
  3. Hint:  Use modulus division in an if-statement within a loop
  4. Add each of the numbers divisible by 5 into a sumOfNums variable, and count how many numbers are divisible by 5 using the countOfNums.
  5. After the loop is over:
  • Display the sumOfNums
  • Calculate the average of the sumOfNums divided by the countOfNums
  • Display the average like this:

“The average of all numbers divisible by 5, starting from 1 to “ + validNum + “ is “ + average

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now