A. Create a Dollar currency class with two integer attributes and one string attribute, all of which are non-public. The int attributes will represent whole part (or currency note value) and...

1 answer below »

A. Create aDollarcurrency class withtwo
integerattributes andone stringattribute, all of which are non-public. Theintattributes will represent whole part (or currency note value) and fractional part (or currency coin value) such that 100 fractional parts equals 1 whole part. Thestringattribute will represent the currency name.


B. Create aCIS22C Dollarderived/inherited class withoneadditional non-publicdoubleattribute to represent the conversion factor from/to US Dollar.



  • The value of the conversion factor can be defaulted in the class definition based on 1 USD = 1.36 C2D or 1 C2D = 0.74 USD.

  • Also, 1000 of C2D fractional parts equals 1 C2D whole part.


C. In your two currency classes, add public methods for the following:



  • Default Construction (i.e. no parameters passed)

  • Construction based on parameters for all attributes

  • Copy Constructor and/or Assignment, as applicable to your programming language of choice

  • Destructor, as applicable to your programming language of choice

  • Setters and Getters for all attributes

  • Adding two objects of the same currency

  • Subtracting one object from another object of the same currency

  • Comparing two objects of the same currency for equality/inequality

  • Comparing two objects of the same currency to identify which object is larger or smaller

  • Print method to print details of a currency object

  • In your derived class only, methods to convert USD objects to C2D and vice versa


D. Create aWalletclass with one attribute - an array of twoDollarreferences / pointers and the following methods to demonstrate polymorphism of the currencies:



  • A default Constructor which sets

    • the first element of the array to a zero value Dollar object

    • the second element of the array to a zero value CIS22C Dollar object



  • A Destructor, as applicable to your programming language of choice

  • Methods to add or subtract

    • USD objects to/from the first element only and

    • C2D objects to/from the second element only



  • Methods to compare if the value of either element is greater or smaller than an input value

  • A method to Print the values of the two elements in the Wallet


E. In your main:



  • Create a Wallet object

  • Provide the user a main menu to add/ subtract/ compare the Dollar and CIS22C Dollar values in the Wallet as well as print the contents of the Wallet

  • You can use a second level menu choice to allow the user to select currency type

  • Based on user choice, create either UD or C2d objects as needed to perform the desired operations.

  • The main menu should be run in a loop until the user selects the Exit option

  • There is no sample output - you are allowed to provide user interactivity as you see fit and programs will be graded for clarity of interaction




Things to remember:



  • Create appropriately named code files - for the two Currency classes, for the Wallet class and any other helper code you might need.

  • The file for your main should be named Lab1Main with the appropriate extension.

  • Make any relevant assumptions that you may need but state them clearly in the corresponding code file.

  • Remember to document your methods adequately -pre-post headersas well as any other relevant comments. Also, provide necessary pseudocode of the programin the main.

  • Also, remember to include name blocks in all the code files.

Answered Same DayOct 27, 2021

Answer To: A. Create a Dollar currency class with two integer attributes and one string attribute, all of which...

Aditya answered on Oct 28 2021
159 Votes
public class CIS22C extends Dollar {
// Data Members
final double conversionFactor = 1.36;


// Copy Constructor
public CIS22C(Dollar d) {
super(d);

}

// Default Constructor
public CIS22C() {
     super();
}

// Parametrized Constructor
public CIS22C(int note, int coin, String name) {
super(note, coin, name);

}

// Methods to Calculate the Total currency amount
double USDCurrency1() {
double usdCurrency1;
usdCurrency1 = getNote() + getCoin() / 100;
return usdCurrency1;
}
double USDCurrency2() {
double usdCurrrency2;
usdCurrrency2 = getNote() + getCoin() / 100;
return usdCurrrency2;
}
// Getter for conversion factor
public double getConversionFactor() {
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here