Question: in java 6 . 1 8 ( Displaying a Square of Asterisks ) Write a method squareOfAsterisks that displays a solid square ( the same
in java
Displaying a Square of AsterisksWrite a method squareOfAsterisks that displays a solid square the same number of rows and columns of asterisks whose side is specified in integer parameter side. For example, if side is the method should display
Incorporate this method into an application that reads an integer value for side from the user and outputs the asterisks with the squareOfAsterisks method.
Displaying a Square of Any CharacterModify the method created in Exercise to receive a second parameter of type char called fillCharacter. Form the square using the char provided as an argument. Thus, if side is and fillCharacter is # the method should display
#####
#####
#####
#####
#####
Use the following statement in which input is a Scanner object to read a character from the user at the keyboard:
next returns a String and charAt gets the Strings first character
char fill input.nextcharAt;
Circle Area Write an application that prompts the user for the radius of a circle and uses a method called circleArea to calculate the area of the circle.
Separating DigitsWrite methods that accomplish each of the following tasks:
Calculate the integer part of the quotient when integer a is divided by integer b
Calculate the integer remainder when integer a is divided by integer b
Use the methods developed in parts a and b to write a method displayDigits that receives an integer between and and displays it as a sequence of digits, separating each pair of digits by two spaces. For example, the integer should appear as
Incorporate the methods into an application that inputs an integer and calls displayDigits by passing the method the integer entered. Display the results.
Temperature ConversionsImplement the following integer methods:
Method celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation
celsius fahrenheit ;
Method fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation
fahrenheit celsius ;
Use the methods from parts a and b to write an application that enables the user either to enter a Fahrenheit temperature and display the Celsius equivalent or to enter a Celsius temperature and display the Fahrenheit equivalent.
Find the MinimumWrite a method minimum that returns the smallest of three floatingpoint numbers. Use the Math.min method to implement minimum Incorporate the method into an application that reads three values from the user, determines the smallest value and displays the result.
Perfect Numbers An integer number is said to be a perfect number if its factors, including but not the number itself sum to the number. For example, is a perfect number, because Write a method isPerfect that determines whether parameter number is a perfect number. Use this method in an application that displays all the perfect numbers between and Display the factors of each perfect number to confirm that the number is indeed perfect. Challenge the computing power of your computer by testing numbers much larger than Display the results.
Prime NumbersA positive integer is prime if its divisible by only and itself. For example, and are prime, but and are not. The number by definition, is not prime.
Write a method that determines whether a number is prime.
Use this method in an application that determines and displays all the prime numbers less than How many numbers up to do you have to test to ensure that youve found all the primes?
Initially, you might think that n is the upper limit for which you must test to see whether a number n is prime, but you need only go as high as the square root of n Rewrite the program, and run it both ways.
Reversing Digits Write a method that takes an integer value and returns the number with its digits reversed. For example, given the number the method should return Incorporate the method into an application that reads a value from the user and displays the result.
Greatest Common Divisor The greatest common divisor GCD of two integers is the largest integer that evenly divides each of the two numbers. Write a method gcd that returns the greatest common divisor of two integers. Hint: You might want to use Euclids algorithm. You can find information about it at enwikipedia.orgwikiEuclideanalgorithm. Incorporate the method into an application that reads two values from the user and displays the result.
Write a method qualityPoints that inputs a students average and returns if its if if if and if lower than Incorporate the method into an application that reads a value from the user and displays the result.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
