Question
Create the following programs in Java, {As simple as possible for a Java1 student} a. Ask the user to input a number and pass this
Create the following programs in Java, {As simple as possible for a Java1 student}
a. Ask the user to input a number and pass this number to a method. The method will double the number and return the result. Be sure to print the result on the screen.
b. Ask the user for an integer. Pass this integer into two methods. The first method returns the square of the integer passed to it, and the second method returns the cube. Print the results.
c. The harmonic mean of two numbers is obtained by averaging the inverse of the two numbers and then taking the inverse of the result Write a method that takes two integer arguments and returns the harmonic mean of the two numbers. Ask the user for two integers, invoke your method, then print the harmonic mean.
Note, avoid integer division!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started