Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: having a hard time getting code to coint coins in a piggybank

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs down having a hard time getting code to coint coins in a piggybank

    public class PiggyBankCounter;
    import java.util.*;
     
     public class PiggyBankCounter
    {
    //These variables are declared outside of any method so that they can be used in all methods
    //These variables are static so that they can be used in static methods
    //Arrays are declared with the square brackets to indicate that there will be multiple values of
    //  the same type store in the one variable address
    //USER INPUTS variables
    	static int[] inQuarter;
    	static int[] inDime;
    	static int [] inNickel;
    	static int [] inPenny;
    	static int maxCoinSize
    //program outputs variables
    	static double tCash;
    	static int tQuarters;
    	static int tDimes;
    	static int tNickels;
    	static int tPennies;
     
    public static void main(String[] args)
    {
    	Scanner keyboard = new Scanner(System.in);
    	maxCoinSize = 5000;
    	for (int x = 0; x < maxCoinSize.length; x++)
    			{
    				System.out.print("Please enter total number of quarters you have: ");
    				inQuarter[x] = keyboard.nextLine();
    				System.out.print("Please enter total number of dimes you have: ");
    				inDime[x] = keyboard.nextLine();
    				System.out.print("Please enter total number of nickles you have: ");
    				inNickle[x] = keyboard.nextLine();
    				System.out.print("Please enter total number of pennies you have: ");
    				inPennies[x] = keyboard.nextInt();
    				keyboard.nextLine();
    			}
     
    //Countit Method
    	int Q,N,D,P, qTotal, nTotal, dTotal;
     
      Q = Get inQuarter array size
      N = Get inNickel array size
      D = Get inDime array size
      P = Get inPenny array size
     
    	qTotal = (Q + 1) * 25;
    	nTotal = (n + 1) * 10;
    	dTotal = (d + 1) * 5;
    tCash = (qTotal + nTotal + dTotal + P) / 100 ;
     
     
    //add quarter method
         set quarter array
    	{
    	  int i;
    	  i = Get(inQuarterArraySize);
    	  Set inQuarterArraySize{
    		inQuarterArraySize = i ++;
    		}
    	  tQuarters = i ++;
    	}
     
    	Call CountIt method;
     
    //add Dime method
         set Dime array
    	{
    	  int i;
    	  i = Get(inDimeArraySize);
    	  Set inDimeArraySize{
    		inDimeArraySize = i + 1;
    		}
    	  tDimes = i + 1;
    	}
     
    	Call CountIt method;
     
    //add Nickel method
         set Nickel array
    	{
    	  int i;
    	  i = Get(inNickelArraySize);
    	  Set inNickelArraySize{
    		inNickelArraySize = i + 1;
    		}
    	  tNickels = i + 1;  // show total nickels in bank to user
     
     
    	Call CountIt method;
     
    //add Penny method
         set Penny array
    	{
    	  int i;
    	  i = Get(inPennyArraySize);
    	  Set inPennyArraySize{
    		inPennyArraySize = i + 1;
    		}
    	}
     
    	Call CountIt method;


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: having a hard time getting code to coint coins in a piggybank

    Please explain what problems you are having. Post any output that shows the problem and add some comments explaining what is wrong with the output.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Hard time understanding.
    By Bantertrix in forum Java Theory & Questions
    Replies: 1
    Last Post: April 15th, 2013, 07:31 AM
  2. Hard time with Strings
    By Aboyordie in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 4th, 2012, 10:58 PM
  3. I am having a hard time with my code
    By SandeeBee in forum What's Wrong With My Code?
    Replies: 14
    Last Post: November 12th, 2011, 09:34 AM
  4. Having a hard time figuring out how to make my code work
    By iainnitro in forum Loops & Control Statements
    Replies: 2
    Last Post: September 6th, 2011, 07:48 AM
  5. new to java.... having a hard time trying to read code
    By Newbie_96 in forum Java Theory & Questions
    Replies: 2
    Last Post: August 6th, 2011, 01:51 AM