Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given three int variables that have been declared and given values areaCode, exc

ID: 441058 • Letter: G

Question

Given three int variables that have been declared and given values areaCode, exchange, and lastFour, write a string expression whose value is the sting equivalent of each these variables joined by a single hyphen(-) so if areaCode, exchange, and lastFour, had the value 800, 555, and 1212, the expression's value would be "800-555-1212".

Explanation / Answer

Hey, Just take a character array some size which is good enough to hold the result. A good option would be -> areaCode.length()+exchange.length()+2 Now start with the index 0 and populate this array with the area code, once done, place a hyphen (-) on the next character. Now populate the array with the next field, exhange, then again a hyphen and then do the same with the lastfour. When you print this character array now, you are done. Cheers! Please rate :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote