repl.it
@imigames/

change 2.0

Java

No description

fork
loading
Files
  • Main.java
  • money_convert.java
  • test
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.Scanner;

public class Main
{

    public static void main(String[] args) 
    {   
        System.out.println("Enter the amount of money in cents.");        
        Scanner input = new Scanner(System.in);
        //entire value of money, to be split into dollars, quarters, etc.

        int money = input.nextInt();
        int pounds = 0, fifthy = 0, twenty = 0, ten = 0 ,five = 0, one = 0;


         int c_five = 20;
         int c_ten = 20;
         int c_twenty = 20;
         int c_fifty = 20;
         int c_pounds = 10;
        //asks for the amount of money



        //checking for dollars, and leaving the change
        if(money >= 100)
        {
            pounds = money / 100;
            c_pounds -= pounds;
            money = money % 100;
        }
            //less then 100
            fifthy = money / 50;
            money = money % 50;
            twenty = money / 20;
            money = money % 20;
            ten = money / 10;
            money = money % 10;
            five = money / 5;
            money = money % 5;        
            one = money / 1;
            money = money % 1;


        //result
        System.out.println("Pounds: " + pounds + ", 50p: " + fifthy + ", 20p: " + twenty + ", 10p: " + ten + ", 5p: " + five +", 1p: " + one);
        
                System.out.println(c_pounds);
        System.out.println(c_fifty);
        System.out.println(c_twenty);
        System.out.println(c_ten);
        System.out.println(c_five);
    }

}