id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > quiz2023_09_26_APP1SLHL_longerOrShorter
prev  |  next  |  chance

Write a method that determines if the string 'str' is shorter, longer, or the same size as the integer 'size'. If 'str' is shorter, return a value of -1. If 'str' is the same size as 'size', return 0. If 'str' is longer, return a value of 1. For example, if 'str' is "This is a really long sentence.", and 'size' is 5, then you would return a 1 because the string is longer than the length indicated by 'size'.


quiz2023_09_26_APP1SLHL_longerOrShorter("testing", 3) → 1
quiz2023_09_26_APP1SLHL_longerOrShorter("A", 1) → 0
quiz2023_09_26_APP1SLHL_longerOrShorter("A", 3) → -1

...Save, Compile, Run (ctrl-enter)

public int quiz2023_09_26_APP1SLHL_longerOrShorter(String str, int size) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 230

Copyright Nick Parlante 2017 - privacy