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

 

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

For this problem you must limit the number of conditionals you use. You are not allowed to use more than 6 conditional statements including "if" and the tertiary conditional "?". Write a method that returns the score you earn during a turn of a game. In this game, you flip four coins simultaneously. For each coin that comes up "heads" (represented by a boolean parameter being 'true') your score goes up. If all coins are tails (all booleans are 'false') you earn 0 points. If any ONE coin is heads you earn 1 point. If any TWO coins are heads you earn 10 points. If any THREE coins are heads you earn 100 points. If ALL of the coins are heads you earn 1000 points. Remember, you may use AT MOST 6 conditional statements!


jan8_2016_SLHLgameScore(true, true, true, false) → 100
jan8_2016_SLHLgameScore(true, false, false, false) → 1
jan8_2016_SLHLgameScore(false, true, false, false) → 1

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

public int jan8_2016_SLHLgameScore(boolean b1, boolean b2, boolean b3, boolean b4) { }

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

Copyright Nick Parlante 2017 - privacy