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

# Thread: Can someone help with my code and psuedocode.

1. ## Can someone help with my code and psuedocode.

I am new to programing and am taking intro to Java this semester. First project is program that determines least amount of bills and coins of a given amount. It is very basic and also was told to include the psuedocode in the code. Please any feedback is appreciated but please don't be to harsh.

```/*
* Program will prompts for monetary value and display amount in bill and coins.
* The total amount is entered in with keyboard.
* Bills and coins are calculated by dividing total by bill amount and again with remaining balance divided so on and ...
*
* - Inputs:
* totalamount in entered from keyboard.
*
* - Processing:
* totalamount is multiplied by 100 to convert to cents.
* Value is then divided by 1000 to find amount of ten dollar bills in amount.
* The remainder of operation is then divided by 500 to find amount of five dollar bills in amount.
* The remainder of operation is then divided by 100 to find amount of one dollar bills in amount.
* The remainder of operation is then divided by 25 to find amount of quarters in amount.
* The remainder of operation is then divided by 10 to find amount of dimes in amount.
* The remainder of operation is then divided by 5 to find amount of knickels in amount.
*
*
*
* - Outputs:
* Display amount of ten dollar bills in totalamount.
* Display amount of five dollar bills in totalamount.
* Display amount of dollar bills in totalamount.
* Display amount of quarters in totalamount.
* Display amount of dimes in totalamount.
* Display amount of pennies in totalamount.
*
* @author Robert Gonzalez
* @version 1.1
*
*/
import java.util.Scanner;
public class changeBack {
/**
* Calculates fewest number of each bill and coin needed to represent that input amount.
* @param args A String array containing command-line parameters.
*/
public static void main(String[] args)
{
double totalamount;
double remainbalance;
int tenbills;
int fivebills;
int dollars;
int quarters;
int dimes;
int knickels;
int pennies;

Scanner input = new Scanner(System.in);
//Get the total amount to calculate change
System.out.print("How much money do you have in your pocket? ");
totalamount = input.nextDouble();

//Calculate amount of bills and coins

totalamount =(totalamount*100);
tenbills = (int) totalamount/1000;
remainbalance = totalamount%1000;
fivebills= (int)remainbalance/500;
remainbalance = totalamount%500;
dollars= (int)remainbalance/100;
remainbalance = totalamount%100;
quarters= (int)remainbalance/50;
remainbalance = totalamount%50;
dimes= (int)remainbalance/10;
remainbalance = totalamount%10;
knickels= (int)remainbalance/5;
remainbalance = totalamount%5;
pennies= (int)remainbalance;

//Displays the outputs
System.out.println("That amount brakes down to:");
System.out.println(tenbills + " ten dollar bills");
System.out.println(fivebills + " five dollars bills");
System.out.println(dollars + " dollar bills");
System.out.println(quarters + " quarters");
System.out.println(dimes + " dimes");
System.out.println(knickels + " knickels");
System.out.println(pennies + " pennies");
}
}```  Reply With Quote

3. ## Re: Can someone help with my code and psuedocode.

Hello, what is your actual problem? Are you having issues creating psuedocode? Psuedocode has many tutorials on how to do.  Reply With Quote

4. ## The Following User Says Thank You to Tjstretch For This Useful Post:

Hazmat210 (February 3rd, 2012)

5. ## Re: Can someone help with my code and psuedocode.

Thanks for the reply so essentially the psuedocode should have the same amount of lines as the code? I am new to forums and do not know the rules here I will wrap the code as soon as I figure out how.  Reply With Quote

6. ## Re: Can someone help with my code and psuedocode.

post with pseudo code guidelines, so that i can able to help you  Reply With Quote

7. ## The Following User Says Thank You to kb18001 For This Useful Post:

Hazmat210 (February 3rd, 2012)

8. ## Re: Can someone help with my code and psuedocode.

Sorry, professor asked us to include it at the very begining of our code. I am also not sure if the bills needs to be in the inputs.

/*
* Program will prompt for monetary value and display amount in bill and coins.
* The total amount is entered in with keyboard.
* Bills and coins are calculated by dividing total by bill amount and again with remaining balance divided so on and ...
*
* - Inputs:
* totalamount in entered from keyboard.
*
* - Processing:
* totalamount is multiplied by 100 to convert to cents.
* Value is then divided by 1000 to find amount of ten dollar bills in amount.
* The remainder of operation is then divided by 500 to find amount of five dollar bills in amount.
* The remainder of operation is then divided by 100 to find amount of one dollar bills in amount.
* The remainder of operation is then divided by 25 to find amount of quarters in amount.
* The remainder of operation is then divided by 10 to find amount of dimes in amount.
* The remainder of operation is then divided by 5 to find amount of knickels in amount.
*
*
*
* - Outputs:
* Display amount of ten dollar bills in totalamount.
* Display amount of five dollar bills in totalamount.
* Display amount of dollar bills in totalamount.
* Display amount of quarters in totalamount.
* Display amount of dimes in totalamount.
* Display amount of pennies in totalamount.
*
* @author Robert Gonzalez
* @version 1.1
*  Reply With Quote