Skip to content

Instantly share code, notes, and snippets.

@benfb
Created September 23, 2012 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfb/3773008 to your computer and use it in GitHub Desktop.
Save benfb/3773008 to your computer and use it in GitHub Desktop.
Invoke
// name:
// purpose: demonstrate further method prowess
public class BBaileyInvoke
{
// method piggyBank(): returns what the change is worth in cents
public static int piggyBank(int pennies, int nickles, int dimes, int quarters, int halfDollars) //creates the piggyBank method, which takes the arguments pennies, nickles, dimes, quarters, and halfDollars
{
double money = (pennies *.01) + (nickles*.05) + (dimes*.1) + (quarters*.25) + (halfDollars*.5); //calculates the amount of money needed
return ((int)(money*100)); //returns the amount of money as an integer in cents
}
// method mp3Sizer(): estimates the number of gB needed to store media
public static int mp3Sizer(int songs, int videos, int photos) //creates the mp3Sizer method, which accepts the arguments songs, videos, and photos
{
final double songsize = 3.04; //creates a constant that tells Java how big songs are in megabytes
final double videosize = 89.3; //does the same for videos
final double photosize = 1.72; //does the same for photos
double gb = (Math.ceil(((songsize*songs) + (videosize*videos) + (photosize*photos))/1024)); //calculates the size in mB, divides by 1024 to get gB, and rounds up
return (int)gb; //returns the the value gb as an integegr
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment