Assignment - PROGRAMMING PROJECT 2.9 Description money2 breaks down a input from user to denominations of money Philippe Farrugia import

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
PROGRAMMING PROJECT 2.9 /** * Description: money2 breaks down a input from user to denominations of money * * Philippe Farrugia * October 21 2010 */ import java.util.Scanner; public class money2{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the amount to be broken down: "); double amount = scanner.nextDouble(); // specified monetary denomination breakdown. double[] coins = {0.01, 0.05, .1, 0.25, 0.5, 1, 5, 10}; double[] soln = new double[coins.length]; double current = 0.0; int i = coins.length - 1; while(i >= 0) //variable set
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ double val = coins[i]; while((val + current) <= amount) { current = current + val; soln[i] = soln[i] + coins[i]; } i--; } System.out.println(current); //nested loop with while loop inside, if it is small enough to add another for(int j = 0;j < coins.length; j++) { System.out.println(coins[j] + " : " + soln[j] / coins[j]); } } } PROGRAMMING PROJECT 2.10 /** * Measurement of one side of square converted to perimeter and area * * Philippe Farrugia * Oct 14, 2010
Background image of page 2
*/ import java.util.Scanner; public class SquareSides6 { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the length of the square's side in centimeters: "); int side = scanner.nextInt(); System.out.println ("Permimeter of the square is: " + (side * 4)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2010 for the course IT IT101 taught by Professor Testing during the Spring '10 term at University of Toronto- Toronto.

Page1 / 11

Assignment - PROGRAMMING PROJECT 2.9 Description money2 breaks down a input from user to denominations of money Philippe Farrugia import

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online