Click here to Skip to main content
15,892,805 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How could I remove "
Â
"?

Could you please help me with this question? Thank you!

What I have tried:

Recently I wrote this code:

Java
import java.util.Scanner;

public class CashPoint {
    public static void main(String[] args){
        Scanner Scan = new Scanner(System.in);

        int note50 = 0;
        int note20 = 0;
        int note10 = 0;
        int note5 = 0;

        System.out.print("Enter amount: ");
        int amount = Scan.nextInt();

        if (amount < 5){
            System.out.println ("The amount is too small.");
        }else{
            if (amount > 250){
                System.out.println ("The amount exceeds the daily limit of withdrawals.");
            }else{
            if (amount >=50){
                note50 = amount/50;
                amount = amount - note50 * 50;
            }
            if (amount >=20){
                note20 = amount/20;
                amount = amount - note20 *20;  
            }
            if (amount >=10){
                note10 = amount/10;
                amount = amount - note10 * 10;
            }
            if (amount >=5){
                note5 = amount/5;
                amount = amount - note5 * 5;
            } 
            
            System.out.println("Notes given out are: ");
            System.out.println("£50 = " + note50);
            System.out.println("£20 = " + note20);
            System.out.println("£10 = " + note10);
            System.out.println("£5 = " + note5);

            
            }
        }
    }
}


However, it shows
£50 = 4
£20 = 1
£10 = 1
£5 = 1
Posted
Updated 21-Jan-22 3:20am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900