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_dollarsAndCents
prev  |  next  |  chance

Write a method that returns a string showing the amount of money you have in dollars and decimal fractions of dollars (also known as "cents"). For example, if 'dollars' is 12 and 'cents' is 3, you would return the string "$12.03". Note that the placement of the "3" matters. Returning "$12.3" is incorrect in this case as that would mean you had 30 cents, not 3 cents. As preconditions, you may assume that dollars>=0 and 0<=cents<=99 (Note: This is NOT valid Java code! It does have a mathematical meaning though.) Look at the test data for examples. Note: This does not require some fancy code that you haven't learned yet! It can be done just using what you already are supposed to know.


quiz2023_09_26_APP1SLHL_dollarsAndCents(17, 23) → "$17.23"
quiz2023_09_26_APP1SLHL_dollarsAndCents(41, 7) → "$41.07"
quiz2023_09_26_APP1SLHL_dollarsAndCents(0, 0) → "$0.00"

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

public String quiz2023_09_26_APP1SLHL_dollarsAndCents(int dollars, int cents) { }

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