assignment - PROGRAMMING PROJECT 2.9 Description money2...

Info icon This 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
Image of page 1

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

View Full Document Right 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
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)
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern