Friday, September 25, 2020

US Dollar Money Exchange Solver in Java

 I will show you write a program that takes as input any change expressed in cents. It should then compute the number of half-dollars, quarters, dimes, nickels, and pennies to be returned, returning as many half dollars as possible, the quarters, dimes, nickels, and pennies, in that order. For example, 493 cents should return 9 half dollars, 1 quarter, and 1 dime, and 1 nickel and 3 pennies using Java

programming language.

Note: US half dollar = 50 cents, quarter = 25 cents, dime = 10 cents, nickel = 5 cents, and penny = 1 cent. 

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.



Program Listing

/**
 * 
 */
package us_money_exchange;

import java.util.Scanner;

/**
 * @author Jake Rodriguez Pomperada, MAED-IT, MIT
 * jakerpomperada@gmail.com
 * www.jakerpomperada.com
 * Bacolod City, Negros Occidental
 * September 25, 2020  Friday
 */
public class US_Dollar_Money_Exchange {

/**
* @param args
*/
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
 
int us_dollar=0;
  int halfDollar=0, quarter=0;
int dime=0, penny=0,nickel=0;
        
        System.out.println("\n");
    System.out.print("\t\tUS Dollar Money Exchange Solver in Java");
    System.out.println("\n");
    System.out.print("\tGive amount in US Dollar Cents : ");
       
    us_dollar  = reader.nextInt();
        
        System.out.println();
        
halfDollar=(us_dollar/50);
us_dollar=(us_dollar%50);
quarter=(us_dollar/25);
us_dollar=(us_dollar%25);
dime=(us_dollar/10);
us_dollar=(us_dollar%10);
      nickel= (us_dollar/5);
penny= (us_dollar%5);

System.out.print("\tDisplay Results");
System.out.print("\n\n");
System.out.println("\tHalf Dollars : " + halfDollar);
System.out.println("\tQuarters     : " + quarter);
System.out.println("\tDime         : " + dime);
System.out.println("\tNickle       : " + nickel);
System.out.println("\tPennys       : " + penny);
System.out.print("\n");
System.out.println("\tEnd of Program");
        System.out.println("\n\n");

}

}

No comments:

Post a Comment