Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method named removeSpaces. The method receives a String and returns a String. The method returns a String that has all of the received

Write a method named removeSpaces. The method receives a String and returns a String. The method returns a String that has all of the received Strings whitespace characters removed. The returned String has all of the same characters as the received string except for all whitespace characters. The returned String has all characters (except whitespace) in the same order as they were in the received String. If the received String is all whitespace characters then the method returns an EMPTY String.
method signature: public static String removeSpaces(String word)
Example values:
removeSpaces(Hi There! ) should return HiThere!
removeSpaces( whats up ??) should return whatsup??
removeSpaces( YYYY \t\t YYY ) should return YYYYYYY
removeSpaces(" ") should return ""
Write a method named toCelsius, the method receives a double, temperature in Fahrenheit, returns the equivalent temperature in Celsius. (Look up a conversion formula, be sure that you use double type values in your formula).
method signature: public static double toCelsius(double temperature)
Example values:
toCelsius(212.0) should return 100.0
toCelsius(32.0) should return 0.0
toCelsius(100.0) should return 37.77777
toCelsius(-100.0)should return -73.333333334
Write a method named getLetterGrade. The method receives a grade average (double) returns the corresponding letter grade - use 90.0,80.0,70.0, 60.0 as cutoffs for A, B, C, D, F. Any grade average received that is below 0.0 or over 105.0 return 'X'
method signature: public static char getLetterGrade(double gradeAvg)
Example values:
getLetterGrade(90.0) should return 'A'
getLetterGrade(85.2) should return 'B'
getLetterGrade(69.9) should return 'D'
getLetterGrade(78.33) should return 'C'
getLetterGrade(110.0) should return 'X'
getLetterGrade(104.3) should return 'A'
Write a method, getFirstLast, the method receives a String and returns a String containing the first and last characters in the received string ignoring leading/trailing spaces.
method signature: public static String getFirstLast(String aString)
Example values:
getFirstLast("Hi There!") should return "H!"
getFirstLast("Seu") should return "Su"
getFirstLast("Q") should return "Q" // note that 1 letter is both first and last
getFirstLast(" A CDG jk B ") should return "AB" so remove leading/trailing spaces
getFirstLast(" ") should return "" //
getFirstLast("") should return "" // empty string should return empty string
Write a method doubleChars, that returns a String containing all chars in the received String appearing two times in the returned String.
method signature: public static String doubleChars(String str)
doubleChars("The") returns "TThhee"
doubleChars("AAbb") returns "AAAAbbbb"
doubleChars("Hi-There") returns "HHii--TThheerree"
doubleChars("") returns ""
doubleChars(" ") returns " "
Write a method mixIt, that receives 2 strings and returns a string containing the first char of string1, the first char of string2, the second character of string1, the second character of string2 etc. Any leftover chars go at the end of the returned string
method signature: public static String mixIt(String str1, String str2)
mixIt("abc", "xyz")returns "axbycz"
mixIt("Hi", "There") returns "HTihere"
mixIt("xxxx", "There")returns "xTxhxexre"
Write a method, computeTicketCode, that receives a vehicle's speed(int) detected by radar camera , and a boolean(isSchoolZone). Return appropriate code depending on received values as described below:
method signature: public static int computeTicketCode(int speed, boolean isSchoolZone)
When NOT in a school zone: (false value received for isSchoolZone)
speed code
0-30 0
31-59 1
60-75 2
75+ 3
When IN a school zone (true value received for isSchoolZone)
speed code
0-20 0
21-50 1
51-60 2
61+ 3
English language

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions