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

 

tmhscs@gmail.com competition > HPCW2020_03_SodaTables
prev  |  next  |  chance

Soda Tables
Problem 03
Worth 2 points

Taylor has X cans of regular soda and Y cans of diet soda. He wants to create some identical refreshment
tables for a party at his school. He also doesn't want to have any sodas left over. Write a program to find the
greatest number of refreshment tables that Taylor can stock.

You will receive 2 lines of input, the first will be "X" and the second will be "Y".

The goal is to set out the largest number of tables with identical sets of refreshments, using all of the available
cans of soda. To do that, look for the largest number which divides evenly into both X and Y. In this case, X=6
can be divided by 1, 2 and 3 evenly. And Y=15 can be divided by 1, 3, and 5 evenly. So 3 is the largest divisor
they both share.

HPCW2020_03_SodaTables(6, 15) → 3
HPCW2020_03_SodaTables(78, 42) → 6
HPCW2020_03_SodaTables(1, 2) → 1

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

public int HPCW2020_03_SodaTables(int x, int y) { }

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

Post-solution available

Copyright Nick Parlante 2017 - privacy