Question: in java 6 . 1 8 ( Displaying a Square of Asterisks ) Write a method squareOfAsterisks that displays a solid square ( the same

in java
6.18(Displaying a Square of Asterisks)Write 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 4, 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.
6.19(Displaying a Square of Any Character)Modify the method created in Exercise 6.18 to receive a second parameter of type char called fillCharacter. Form the square using the char provided as an argument. Thus, if side is 5 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(0) gets the Strings first character
char fill = input.next().charAt(0);
6.20(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.
6.21(Separating Digits)Write 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 1 and 99999 and displays it as a sequence of digits, separating each pair of digits by two spaces. For example, the integer 4562 should appear as
4562
Incorporate the methods into an application that inputs an integer and calls displayDigits by passing the method the integer entered. Display the results.
6.22(Temperature Conversions)Implement the following integer methods:
Method celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation
celsius =5.0/9.0*(fahrenheit -32);
Method fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation
fahrenheit =9.0/5.0* celsius +32;
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.
6.23(Find the Minimum)Write a method minimum3 that returns the smallest of three floating-point numbers. Use the Math.min method to implement minimum3. Incorporate the method into an application that reads three values from the user, determines the smallest value and displays the result.
6.24(Perfect Numbers) An integer number is said to be a perfect number if its factors, including 1(but not the number itself), sum to the number. For example, 6 is a perfect number, because 6=1+2+3. 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 1 and 1000. 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 1000. Display the results.
6.25(Prime Numbers)A positive integer is prime if its divisible by only 1 and itself. For example, 2,3,5 and 7 are prime, but 4,6,8 and 9 are not. The number 1, 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 10,000. How many numbers up to 10,000 do you have to test to ensure that youve found all the primes?
Initially, you might think that n/2 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.
6.26(Reversing Digits) Write a method that takes an integer value and returns the number with its digits reversed. For example, given the number 7631, the method should return 1367. Incorporate the method into an application that reads a value from the user and displays the result.
6.27(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 en.wikipedia.org/wiki/Euclidean_algorithm.] Incorporate the method into an application that reads two values from the user and displays the result.
6.28 Write a method qualityPoints that inputs a students average and returns 4 if its 90100,3 if 8089,2 if 7079,1 if 6069 and 0 if lower than 60. 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!