[Solved] ITI1121: Assignment #1

30 $

File Name: ITI1121:_Assignment_#1.zip
File Size: 207.24 KB

SKU: [Solved] ITI1121: Assignment #1 Category: Tag:

Or Upload Your Assignment Here:


Part I: Written answer questions (20) ( submit a .pdf file)

Answer the following questions using no more than the available space:

1. The company Java Financial Solutions is developing a new software system for tracking professional expenses. You are part of the software development team responsible for the hierarchy of classes to represent expenses.Specifications: · All expenses have a description (a character string);· All the transportation expenses have a destination (a character string);· A transportation expense using a private car has a distance (of type int);· A transportation expense by air has a fixed amount (of type double) specified when a new transportation expense is created;· All the meal expenses have an attribute which represents the number of meals.· All the expenses have a method to calculate the amount represented by this expense:• The amount for a transportation expense using a private car is a fixed rate times the distance traveled;• The amount for a transportation expense by air is a fixed amount (specified when a new transportation expense is created);• The amount for a meal expense is the number of meals times a fixed rate. The ratedepends on the kind of meal: Breakfast, Lunch or Dinner; You must write the Java implementation of the following classes. Make sure to include the constructors, the access methods and where appropriate the method for calculating the amount represented by the expense.A. Expense B. Transportation C. PrivateCar D. Airfare E. Meal F. Breakfast G. Complete the partial implementation of the class ExpenseTracker below. An Expense-Tracker is used to store Expenses. i) Add the type of the elements of the array expenses. ii)Complete the constructor. iii) Complete the implementation of the method double getTotal().The method double getTotal() returns the total amount for all the expenses that arecurrently stored in the ExpenseTracker. public class ExpenseTracker {private __________ [] expenses;private int size; // keeps track of the number of elementspublic ExpenseTracker( int capacity ) {__________________________________;size = 0;}// a method has been defined for adding expenses to the trackerpublic boolean add( Expense e ) { … }public double getTotal() { }}Below is a test program to help you understand the work that needs to be done for this question.public class Run {public static void main( String[] args ) {ExpenseTracker epro = new ExpenseTracker( 10 );epro.add( new PrivateCar( “ACFAS 2004”, “Montreal (QC)”, 430 ) );epro.add( new Airfare( “IWBRA 2005”, “Atlanta (GA)”, 204.0 ) );epro.add( new Breakfast( “IWBRA 2005”, 2 ) );epro.add( new Lunch( “IWBRA 2005”, 3 ) );epro.add( new Dinner( “IWBRA 2005”, 2 ) );System.out.println( “total = ” + epro.getTotal() );}}Its output is as follows: total = 508.21000000000004
2. Consider the following declarations: package pack1;public class Class1 {private int v1;protected int v2;int v3;public int v4;}package pack1;public class Class2 {…}package pack2;public class Class3 extends pack1.Class1 {…}package pack2;public class Class4 {…}a. What visibility must variables declared in pack1.Class1 have in order to be visible in pack1.Class2? b. What visibility must variables declared in pack1.Class1 have in order to be visible in pack2.Class3? c. What visibility must variables declared in pack1.Class1 have in order to be visible in pack2.Class4?

Part II: Programming Module (80 marks):

  • Note: Please download and use the classes : BankGUI, BankApp
    • As well as the interface for the class Bank
  • For each class, add comments (documentation) describing the variables and methods used.
  • The following are the values for the constants in the classes: Senior, Adult and Student:
SAVINGS_INTEREST CHECK_INTEREST CHECK_CHARGE OVERDRAFT_PENALTY
Adult 0.03 (3%) 0.01 3 cents $25
Student 0.07 0.03 2 cents $20
Senior 0.08 0.04 1 cent $10

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] ITI1121: Assignment #1
30 $