King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Similar documents
King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Final Project Option #1 Restaurant Simulation

Computer Science 1 Program 4 TA Lab (Stacks & Queues) Assigned: 3/2/11 Due: 3/23/11 (Wednesday) at 11:55pm (WebCourses time)

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am

ASSIGNMENT TWO: PHONE BOOK

CS112 Lecture: Defining Instantiable Classes

Community Service Project/Critical Thinking Class (Deadlines)

Lab Exercise 6: Abstract Classes and Interfaces CS 2334

Jawwal System (Linked Lists)

CS 142 Style Guide Grading and Details

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

Introduction to Programming II Winter, 2015 Assignment 5 (Saturday, April 4, 2015: 23:59:59)

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

Homework Assignment #3

CS 2704 Project 3 Spring 2000

Initial Coding Guidelines

UNIVERSITY OF MASSACHUSETTS LOWELL Department of Electrical and Computer Engineering. Program 9 EECE.3220 Data Structures Fall 2017

CpSc 1111 Lab 9 2-D Arrays

Storing Data in Objects

COMP 346 Winter 2019 Programming Assignment 2

EXAM Computer Science 1 Part 1

Remaining Enhanced Labs

CS61BL: Data Structures & Programming Methodology Summer Project 1: Dots!

Tips from the experts: How to waste a lot of time on this assignment

Assessment details for All students Assessment item 1

UNIVERSITY OF MASSACHUSETTS LOWELL Department of Electrical and Computer Engineering. Program 8 EECE.3220 Data Structures Fall 2017

Linked Lists. College of Computing & Information Technology King Abdulaziz University. CPCS-204 Data Structures I

Programming Assignment 5 (100 Points) START EARLY!

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

Object-Oriented Programming for Managers

CSE Spring 2015 Homework #1 Assigned January 22 nd, 2015, 2:00 pm Due: February 5 th, 2015, 2:00 pm

CS 241 Data Organization. August 21, 2018

CSE 143 Final Part 1, August 18, 2011 Sample Solution

Writeup for first project of CMSC 420: Data Structures Section 0102, Summer Theme: Threaded AVL Trees

Programming Assignment HW5: CPU Scheduling draft v04/02/18 4 PM Deadline April 7th, 2018, 5 PM. Late deadline with penalty April 9th, 2018, 5 PM

11 Data Structures Foundations of Computer Science Cengage Learning

EE 422C HW 6 Multithreaded Programming

************ THIS PROGRAM IS NOT ELIGIBLE FOR LATE SUBMISSION. ALL SUBMISSIONS MUST BE RECEIVED BY THE DUE DATE/TIME INDICATED ABOVE HERE

CSCI 1301: Introduction to Computing and Programming Spring 2019 Lab 10 Classes and Methods

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists

EECE.4810/EECE.5730: Operating Systems Spring 2018 Programming Project 3 Due 11:59 PM, Wednesday, 4/18/18 Monday, 4/30/18

INFO 2313: Project. School of Business Kwantlen Polytechnic University. Nov 19, 2016 It is due at 12:00 PM (noon) on Sunday, Dec 4, 2016

CS 3114 Data Structures and Algorithms DRAFT Project 2: BST Generic

CMPSCI 187 / Spring 2015 Hangman

CMSC 201 Fall 2016 Homework 6 Functions

Programming Assignment 2 ( 100 Points )

San José State University Department of Computer Science CS151, Object Oriented Design, Section 04, Fall, 2016 (42968)

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

CMPSCI 187 / Spring 2015 Sorting Kata

Project 4: ATM Design and Implementation

CSCI 1301: Introduction to Computing and Programming

Computer Security Spring 2010 Paxson/Wagner HW 4. Due Thursday April 15, 5:00pm

CSSE2002/7023 The University of Queensland

CS 202, Fall 2017 Homework #4 Balanced Search Trees and Hashing Due Date: December 18, 2017

Tips from the experts: How to waste a lot of time on this assignment

CPS122 Lecture: Defining a Class

Project 1: How to Make One Dollar

Project #3. Computer Science 2334 Fall Create a Graphical User Interface and import/export software for a Hurricane Database.

Circular Linked List Assignment

PA3: Violet's Vending Venture (Version 3.0)

Web API Lab folder 07_webApi : webapi.jsp your testapijs.html testapijq.html that works functionally the same as the page testapidomjs.

Programming Assignments

CSE100 Principles of Programming with C++

Algorithm Design and Analysis Homework #4

Chapter 5: Arrays. Chapter 5. Arrays. Java Programming FROM THE BEGINNING. Copyright 2000 W. W. Norton & Company. All rights reserved.

CMPSCI 187 / Spring 2015 Hanoi

CMPSCI 187 / Spring 2015 Postfix Expression Evaluator

Spring 2017 CMSC 140 Programming Project 7: Payroll

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Assignment 19 Deadline: Nov pm COSC211 CRN15376 Session 15 (Nov. 7)

Object Oriented Design

CSCE 310 Assignment 3 Summer 2018

The Program Specification:

CS2110 Assignment 3 Inheritance and Trees, Summer 2008

CpSc 1111 Lab 5 Formatting and Flow Control

Assignment 3: Distance COP3330 Fall 2017

CS 2604 Minor Project 1 DRAFT Fall 2000

Java Puzzle Ball MOOC Lab 4: Lambda Expressions

CS 116. Lab Assignment # 1 1

CISC 3130 Data Structures Fall 2018

Announcements for the Class

1st Semester MTCE 601A COMPUTER SYSTEM SOFTWARE

CSE 143: Computer Programming II Summer 2017 HW5: Anagrams (due Thursday, August 3, :30pm)

This handbook contains directions on using tools and resources in WebAccess at CSM.

Programming Assignment 2

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

15-110: Principles of Computing, Spring 2018

ECE 122. Engineering Problem Solving with Java

Lab Exercise 4: Inheritance and Polymorphism CS 2334

Programming Assignment #2

Transcription:

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department CPCS204, 3 rd Term 2014 (Summer) Program1: FCIT Samba Bank Assigned: Wednesday June 11 th, 2014 Due: Thursday June 19 th, 2014 Purpose: 1. The first purpose of this program is for you to REVIEW your JAVA (202 & 203). 2. The second purpose of this program is for you to review file I/O (input/output). 3. Finally, you are to implement binary search in the program. Read Carefully: The deadline for this project is 11:55 PM on Thursday June 19 th, 2014. This program is worth 5% of your final grade. WARNING: This is an individual project; you must solve it by yourself. Any form of cheating will result in receiving -100 (less than zero) in the project. And a -100 is equal to a -5%. Do your own work! WARNING: Late submission will not be accepted. Any project submitted after the cutoff time will receive zero. Email Submission: This project must be submitted online via Email to: cpcs.204@hotmail.com The subject line of your email message should be as the following form: SectionNumber_StudentID_ProjectNumber Example: EA_ 1110348_ P1 The source file(s) of your program should be zipped up. You must name the zip file using the following naming convention: SectionNumber_StudentID_ProjectNumber.zip Example:EA_ 1110348_ P1.zip Discussions: We will randomly select a certain number of students for discussion for each project. If you are chosen for discussion, we will email you with a time. If you do not show up for discussion, you will get a zero for the program.

Program 1: FCIT Samba Bank Objective Review and practice all concepts from CPCS-202, as well as a small review of CPCS-203, with a focus on making classes and creating objects from these classes. Specifically, you will practice making an array of objects and manipulating/using the data inside the array. Finally, and VERY important, this program requires you to read from a file and write to a file (practice with File I/O). This is very important because all programs during the semester will use File I/O. The Problem Samba will be opening a new branch inside FCIT, which will be called FCIT Samba (not really this is just the story of the assignment). The purpose of this program is to design a simulation of the FCIT Samba branch. Students can open accounts at FCIT Samba. They can make withdrawals, deposits, print statements, and more. Each FCIT student can open one bank account at FCIT Samba. You will write a program that will simulate normal activities of FCIT Samba. During the program, the following things can occur (just as in a normal bank): New accounts can be created. Note: when new accounts are added for the first time, they are initialized with an opening balance (given in the input file). It is guaranteed that newly added accounts will always have a positive balance. A customer can request the balance on the account. A customer can deposit any amount into his account. A customer can withdraw money from his account (if the money is available). A customer can transfer amount from his account into another account. In this case the balance of the former customer will be reduced, while the balance of the later customer will increased accordingly. A customer can close his account. A list of daily transactions can be printed. You will use File I/O to read input from a file and then print the output to a file. To be clear, you will read COMMANDS from an input file. Example commands are OPENACCOUNT, DEPOSIT, WITHDRAW, TRANSFER, FINDACCOUNT, CLOSEACCOUNT, TRANSACTIONREPORT etc. Then, depending on the command, you will either add a new account, deposit amount, withdraw amount, transfer amount, close account, etc. But instead of printing to the console window (screen), you will need to print it to an output file. *Sample input and output files have been provided for you on the website.

Input File Specifications You will read in input from a file, "FCITsamba.in". Have this AUTOMATED. Do not ask the user to enter FCITsamba.in. You should read in this automatically. Note: a *.in file is just a regular text file. Also, a *.out file is a regular text file. Do not be scared by this. Instead of calling the input and output file as input.txt and output.txt, it is better for those files to have a good name. Therefore, the input file will be called FCITsamba.in and the output file will be called FCITsamba.out. The first line of the file will be an integer representing the maximum number of accounts in the bank. The second line of the file will be an integer representing the maximum possible number of recorded transactions for any given day of the simulation. The third line of the file will be an integer, d, representing the number of days for the simulation. For each day, there will be an integer k on the first line, followed by k commands, with each command on a new line and followed by appropriate data (and this relevant data will be on the same line as the command). Output File Specifications Your program must output to a file, called "FCITsamba.out". You must follow the program specifications exactly. You will lose points for formatting errors and spelling. Sample and Output Files A sample input file, with corresponding output file, can be found on the Moodle (the files have too many lines to paste here). NOTE: These files do NOT test every possible scenario. That is the job of the programmer to come think up the possible cases and test for them accordingly. You can be sure that our graders will grade with very large input files, which are intended to, ideally, test all possible cases. It is recommended that you spend time thinking of various test cases and build your own input file for testing purposes. ***WARNING*** Your program MUST adhere to the EXACT format shown in the sample output file (spacing capitalization, use of dollar signs, periods, punctuation, etc). The graders will use very large input files, resulting in very large output files. As such, the graders will use text comparison programs to compare your output to the correct output. If, for example, you have two spaces between in the output when there should be only one space, this will show up as an error even through you may have the program correct. You WILL get points off if this is the case, which is why this is being explained in detail. Minimum deduction will be 10% of the grade, as the graders will be forced to go to text editing of your program in order to give you an accurate grade. Again, your output MUST ADHERE EXACTLY to the sample output.

Implementation For this program, you will have four files. One file will contain main, and the other three files will be classes: FCITstudent, FCITsambaAccount, and FCITsambaTransaction. The class UML diagrams are on the last page of this write-up. The first two lines of the input file are as follows: Line 1: the maximum number of accounts that can be in the bank Line 2: the maximum number of transactions in a given day You must read these values into appropriate variables (maxaccounts and maxtransactions). Next, you will use these new values to make two new arrays: 1. An array of FCITsambaAccount object references 2. An array of FCITsambaTransaction object references - See pages 71-78 of Chapter 8 slides (from 203) for help on array of object references To help you, here is the code to do this: FCITsambaAccount[] accounts = new FCITsambaAccount[maxAccounts]; FCITsambaTransaction[] transactions = new FCITsambaTransaction[maxTransactions]; What do these lines do? They create an array of references. Note: each reference has a default value of null. Until now, we have NOT created any objects. For example, FCITsambaAccount objects are only created when we see the command OPENACCOUNT. At that time, a new FCITsambaAccount object will be created and the reference for that object will be saved in the appropriate location of the array. Commands to Process (from Input File) The commands you will have to implement are as follows: OPENACCOUNT Makes a new account which is added to the bank. The command will be followed by the following information all on the same line: ID, an integer representing the ID number of the student (also the account number for this account); firstname, the first name of the customer/student; lastname, the last name of the customer/student; and openingbalance, the initial amount of for this account. When you read the OPENACCOUNT command, you must make a new object of type FCITsambaAccount. Next, you must scan the additional information (listed above) and save this information into the correct data members of the new object. Note that the firstname, lastname, and ID of the student must be saved into an object of type FCITstudent. How do you do this? Look at the UML diagram for FCITsambaAccount. One of the data members is called student, and the data type for student is FCITstudent. The variable student is a reference variable, but as of now, it is simply pointing to null. Therefore, inside the constructor of FCITsambaAccount, you should make a new FCITstudent object and save that reference into the variable student.

Note also that there is a variable called ID inside the FCITstudent object, and there is also a variable called accountnumber inside the FCITsambaAccount object. These two variables should have the SAME value the ID of the student. Each account will be unique. Meaning, the input file is guaranteed to not have duplicate account added to the bank via the OPENACCOUNT command. Finally, you must save the reference of this object inside the appropriate index of the student array. *Note: this array must stay in sorted order based on the accountnumber. So the account with the smallest accountnumber value will be at index 0, the account with the next smallest at index 1, and so on. Therefore, when you save the object reference into the array, you must first find the correct sorted index. After you find the correct insertion location, if there is no object at that location, then you can easily save the object reference at this index. BUT, IF there is an object at the index that you find, you must SHIFT that object, AND all objects to the right of it, one space to the right. This is how you make a new space in the array for the new object. Example: if your array already has 6 account object references, from index 0 to index 5. And now you want to add a new account object reference at index 4 (based on the sorted location). Before you can add the new account object reference at index 4, you must SHIFT the account object references at index 4 and index 5 to index 5 and index 6. Basically you need to move them one position over to the right. Now, you have an empty spot at index 4 for the new account object reference. PRINTBALANCE This command will be followed by an integer on the same line. This integer represents the account number of the account you must search for. You must perform a Binary Search on your array of FCITsambaAccount object references. If the account is found, you should print the required information for the account. (see output). * There are many possibilities (no accounts at all, this account not found, etc.). See output file for exact scenarios. **We will check your code to confirm you are using Binary Search. You will only earn the points for PRINTBALANCE if you use Binary Search. DEPOSIT This command will be followed by an integer and a double on the same line. This integer represents the account number of the account and the double value represents the amount of money you need to deposit in the account. You must search for the correct account in the accounts array and then deposit the money if the account as found. There are many possibilities (no accounts at all, this account not found, etc.). See output file for exact scenarios. WITHDRAW This command will be followed by an integer and a double on the same line. This integer represents the account number of the account and the double value represents the amount of money you need to withdraw from the account.

You must search for the correct account in the accounts array and then withrdaw the money if the account as found. There are many possibilities (no accounts at all, this account not found, etc.). See output file for exact scenarios. TRANSFER This command will be followed by two integers and a double on the same line. The first integer represents the account number of the account from which money will be deducted, while the second integer represents the account number to which money will be added. The double value represents the amount of money to be transferred. See output for printing examples. CLOSEACCOUNT This command will be followed by an integer. This integer represents the account number to be deleted. You must search for the account and delete it from the system. Here, we will delete simply by saving a difference object reference in its place (see below). *Note: this array must stay in sorted order based on the accountnumber. Again, you must take care of shifting! Example: if your array already has 6 account object references, from index 0 to index 5. And now you want to remove an account object reference at index 3 (based on the sorted location). To remove account object reference at index 3, you must SHIFT the account object references at index 4 to index 3, index 5 to index 4, and index 6 to index 5. Basically you need to move them one position over to the left See output for printing examples. TRANSACTIONREPORT This command will have no other information on the line. When this command is read, a report of all transactions, for that given day, will be printed to the output file. Please refer to sample output for exact specifications. NOTE: When a new day beings, the transaction array must be empty and the variable numtransactions should be reset to zero. *NOTE: Not all commands will result in a transaction. Transactions occur only with commands that change the balance (OPENACCOUNT, DEPOSIT, WITHDRAW, TRANSFER, and CLOSEACCOUNT). Grading Details Your program will be graded upon the following criteria: 1) Adhering to the implementation specifications listed on this write-up. 2) Your algorithmic design. 3) Correctness.

4) Use of Classes, Objects, and Arrays of Objects. If your program is missing these elements, you will get a zero. Period. 5) The frequency and utility of the comments in the code, as well as the use of white space for easy readability. (We're not kidding here. If your code is poorly commented and spaced and works perfectly, you could earn as low as 80-85% on it.) 6) Compatibility to the newest version of NetBeans. (If your program does not compile in NetBeans, you will get a large deduction from your grade.) 7) Your program should include a header comment with the following information: your name, email, course number, section number, assignment title, and date. 8) Your output MUST adhere to the EXACT output format shown in the sample output file. 9) If you are called for discussion, we will email at the SAME EMAIL ADDRESS shown in the header. So make sure you check this email often! Deliverables You should submit a zip file with FOUR files inside: 1. FCITstudent.java 2. FCITsambaAccount.java 3. FCITsambaTransaction.java 4. FCITsamba.java (this is your main program) ***These four files should all be INSIDE the same package called fcitsamba. If they are not in this specific package, you will lose points. NOTE: your name, ID, section number AND EMAIL should be included as comments in all files! Suggestions: Read AND fully understand this document BEFORE starting the program! Next, make the project (the main) in Netbeans. The name will be FCITsamba. This is your main program that will read the commands from the file, process the commands, and print to the output file. Next, add the three classes to the project: o FCITstudent, FCITsambaAccount, and FCITsambaTransaction So make those three classes, with all the data members, constructors, and accessor/mutator methods. Use the IOexample.java program to help you create your main to read from a file and write to a file. Note: the IOexample.java program uses a while loop, because that program stopped execution after reading the QUIT command. However, for your program, you will read a specific number of commands, over a specific number of days. You will need TWO for loops to do this one for loop to iterate over the number of days, and a second for loop to iterate over the number of commands for each day. Finally, one by one, implement the commands (OPENACCOUNT, PRINTBALANCE, DEPOSIT, WITHDRAW, etc). Hope this helps. Final suggestion: START EARLY!

UML Diagrams for Three Classes FCITstudent Data Members private int ID private String firstname private String lastname Operations/Methods FCITstudent() // one or more Constructors ALL getter and setter methods FCITsambaAccount Data Members private int accountnumber private FCITstudent customer private double accountbalance private static int numaccounts FCITsambaTransaction Data Members private String transactiontype private int accountnumber1 private int accountnumber2 private double amount private double balancebefore private double balanceafter private static int numtransactions Operations/Methods FCITsambaTransaction() // one or more Constructors ALL getter and setter methods You should also have a method to increment the numtransactions variable for each time a transaction is added to the transactions array Operations/Methods FCITsambaAccount() // one or more Constructors ALL getter and setter methods You should have also have two additional methods: One to increment numaccounts when you create a new account, and one method to decrement numaccounts when you close an account. You will use the FCITsambaAccount class to create nodes of type FCITsambaAccount, and you will use the FCITsambaTransaction class to create nodes of type FCITsambaTransaction. NOTE: Look at the FCITsambaAccount class. This class has four data members. One of the members is called customer. This variable is of type FCITstudent. What does this mean? This means that when you create a new object of type FCITsambaAccount and you are wanting to save the customer data, you must do one more thing first! Inside the constructor for FCITsambaAccount, you must create a NEW object of type FCITstudent and then save the reference for this object into the variable customer. Now, you will be able to save the data into the correct variables.