Posted: September 16th, 2017

Programming Exercises

EX 1:
What is wrong with the following program?
EX 2:
What is wrong in the following code?
Programming Exercises
EX 1:
(The MyInteger class) Design a class named MyInteger. The class contains:
  • An int data field named value that stores the int value represented by this object.
  • A constructor that creates a MyInteger object for the specified int value.
  • A get method that returns the int value.
  • Methods isEven(), isOdd(), and isPrime() that return true if the value is even, odd, or prime, respectively.
  • Static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively.
  • Static methods isEven(MyInteger), isOdd(MyInteger), and isPrime(MyInteger) that return true if the specified value is even, odd, or prime, respectively.
  • Methods equals(int) and equals(MyInteger) that return true if the value in the object is equal to the specified value.
  • A static method parseInt(int) that converts a string to an int value.
Draw the UML diagram for the class. Implement the class. Write a client program that tests all methods in the class.
EX 2:
(The Account class) Design a class named Account that contains:
  • An int data field named id for the account (default 0).
  • A double data field named balance for the account (default 0).
  • A double data field named annualInterestRate that stores the current interest rate (default 0).
  • A Date data field named dateCreated that stores the date when the account was created.
  • A no-arg constructor that creates a default account.
  • The accessor and mutator methods for id, balance, and annualInterestRate.
  • The accessor method for dateCreated.
  • A method named getMonthlyInterestRate() that returns the monthly interest rate.
  • A method named withDraw that withdraws a specified amount from the account.
  • A method named deposit that deposits a specified amount to the account.
Draw the UML diagram for the class. Implement the class. Write a test program that creates an Account object with an account ID of 1122, a balance of 20000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2500, use the deposit method to deposit $3000, and print the balance, the monthly interest, and the date when this account was created.
Reading Exercise
Read chapter 7. Propose 6 – 12 keywords. Compose 2 – 3 sentences to describe each chapter in a concise, comprehensive, and unambiguous manner.

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Live Chat+1-631-333-0101EmailWhatsApp