Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

3. Define the roles individuals play in a group

Answered: 1 week ago