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

 

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

Write a method that accepts an input string representing chemical compounds or combinations of chemical compounds. Multiple copies are indicated by a number followed by a "/" character. The "~" character is used as a divider. So "5/H~2~O" represents five molecules of water. The desired result is to represent the same chemicals without the special divider symbols. For example, "5/H~2~O" as an input parameter should return "5H2O" as the return value. Look at the test data for other examples. The ONLY string methods you are allowed to use are .length, .charAt, .substring, .equals. In fact, you only NEED two of these string methods! (Or maybe even just one if you are really sneaky and know some advanced stuff)


feb27_2018_APSLHL_chemistry("H~2~O") → "H2O"
feb27_2018_APSLHL_chemistry("") → ""
feb27_2018_APSLHL_chemistry("C~O~2") → "CO2"

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

public String feb27_2018_APSLHL_chemistry(String symb) { }

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: 290

Copyright Nick Parlante 2017 - privacy