Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code a method named insideOut3. The method has one input: a String strthat is at least 3 characters long and of odd length. The output

Code a method named insideOut3. The method has one input: a String strthat is at least 3 characters long and of odd length. The output of the method is a newStringwhere the middle three characters have been removed. Here is some sample input and output:

  • insideOut3("Cartons") "Cans" // rto removed
  • insideOut3("Hip") "" //all three characters removed.
  • insideOut3("Barbara Ann") "Barb Ann" //ara removed


4 THELEFTN PROBLEM

Code a methodleftN. The method has two inputs: aString strand anint n. The output of the method is a newStringthat contains a "rotated left n" version ofstr, where the firstnchars are moved to the end of theString. The originalStringlength will be at leastn. Here is some sample input and output:

  • leftN("Hello", 2) "lloHe"
  • leftN("Chocolate", 3) "colateCho"
  • leftN("Chocolate", 1) "hocolateC"


14 THEDICEPROBLEM

Complete a method namedrollEm. Return the sum of two 6-sided dice rolls, each in the range1..6. However, ifnoDoubles(the third argument) istrue, and, if the two dice show the same value, increment one die to the next value, wrapping around to1if its value was6. Here are some examples.

  • input of 2, 3, true 5
  • input of 3, 3, true 7
  • input of 3, 3, false 6


15 A FIZZYPROBLEM

Code a method namedfizzBuzz. Given anint n, return the number followed by"!". So theint 6returns "6!". Except if the number is divisible by3use"Fizz"instead of the number, and if the number is divisible by5use"Buzz", and if divisible by both3and5, use"FizzBuzz". Do not put the quotes around your result.

  • input of 1 "1!"
  • input of 2 "2!"
  • input of 3 "Fizz!"


16 ANOTHERFIZZYPROBLEM

Code a method namedfizzBuzz. Given an input stringstr, if the string starts with"f"(either upper or lowercase), return"Fizz". If the string ends with"b" (either upper or lowercase), return"Buzz". If both the"f"and"b"conditions aretrue, return"FizzBuzz". In all other cases, return the string unchanged. Do not put the quotes around your result.

  • input of "fig" "Fizz"
  • input of "dib" "Buzz"
  • input of "fib" "FizzBuzz"


17 THEPARTYPROBLEM

Code a method namedpartyOn. We are having a party with amounts ofteaandcrumpets. Return the outcome of the party as"sad","pleasing"or"brilliant". A party is pleasing if bothteaand crumpetsare at least5. However, if eitherteaorcrumpetsis at least double the amount of the other one, the party is brilliant. However, in all cases, if eitherteaor crumpetsis less than5, the party is always sad. Do not put the quotes around your result.

  • input of 6, 8 "pleasing"
  • input of 3, 8 "sad"
  • input of 20, 6 "brillliant"


18 THESPECIALSUMPROBLEM

Code a method namedspecialSum. Return the sum of the twointarguments, aand b. However, "teen" values in the range13..19inclusive, are extra lucky. So if either value is a teen, just return 19.

  • input of 3, 4 7
  • input of 10, 13 19
  • input of 13, 2 19


20 THESPECIALSUMPROBLEM

Code a method namedspecialSum. Return the sum of the twointarguments, aand b. However, sums in the range10..19inclusive, are forbidden, so in that case just return 20.

  • input of 3, 4 7
  • input of 9, 4 20
  • input of 10, 11 21


Step by Step Solution

3.36 Rating (146 Votes )

There are 3 Steps involved in it

Step: 1

Here are the Java methods for the given problems public class Solution Problem 3 Inside Out 3 public ... 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_2

Step: 3

blur-text-image_3

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

Basic Business Statistics Concepts And Applications

Authors: Mark L. Berenson, David M. Levine, Timothy C. Krehbiel

12th Edition

132168383, 978-0132168380

More Books

Students also viewed these Programming questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago