Question
Unit 8-9 Free Response Write four methods : Parts A and B are related and rely on each other for a complete solution Parts C
Unit 8-9 Free Response
Write four methods :
-
Parts A and B are related and rely on each other for a complete solution
-
Parts C and D are related and rely on each other for a complete solution
Part A - Write the method getNumDigits(). getNumDigits returns the number of digits in any given number. All numbers input are positive.
The call getNumDigits(23) would return 2.
The call getNumDigits(34063) would return 5.
public static int getNumDigits( int number ) {
}
Part B - Write the method geDigitDifference. getDigitDifference calculates the number of digits for both parameters and returns the difference between the two calculated values. A negative number should never be returned. Your solution must call getNumDigits() from part A and assume that it works as intended.
The call getDigitDifference(43, 512) would return 1.
The call getDigitDifference(861237, 1) would return 5.
public static int getDigitDifference( int one, int two ) {
}
Part C - Write the method geLetters(). getLetters() returns a String that contains howMany letters.
The call getLetters(4, e) returns eeee
The call getLetters(7, W) returns WWWWWWW
public static String getLetters( int howMany, String thatLetter )
{
}
Part D - Write the method geLetterTriangle(). getLetterTriangle() returns a triangle of letters as shown below. The triangle contains numRows rows of letters and spaces as shown below. You must call getLetters()when writing the method getLetterTriangle().
The call getLetterTriangle(4, U) returns
The call getLetterTriangle(5, W) returns
public static String getLetterTriangle(int numRows, String triLetter){
}
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