73.7k views
0 votes
. Create an abstract Dollar class with two integer attributes, both of which are non-public (Python programmers - it is understood that there is nothing private in Python but try to not access the attributes directly from outside the classes). The int attributes will represent whole part (or currency note value) and fractional part (or currency coin value) such that 100 fractional parts equals 1 whole part.

1 Answer

4 votes

Answer:

Step-by-step explanation:

The following code is written in Java. It creates the abstract dollar class that has two instance variables for the dollars and the coins that are passed as arguments. The test output can be seen in the picture attached below.

class Dollar {

int dollars;

double coin;

private Dollar(int dollar, int coin) {

this.dollars = dollar;

this.coin = Double.valueOf(coin) / 100;

}

}

. Create an abstract Dollar class with two integer attributes, both of which are non-example-1
User Brian Grinstead
by
5.0k points