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.
Code Java:
/*
* 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");
}
}
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.
Also, please wrap your code like so [code=Java]*Code here*[/code]
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.
Re: Can someone help with my code and psuedocode.
post with pseudo code guidelines, so that i can able to help you
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
*