Question Details

(solution) COMP1405B (Fall 2015) Assignment 6 of 6 Due: Monday, December 7th


  • anyone can only provide the code of first question in my assignment?
  • please read and follow the instructions of question 1 carefully, thank you. 

COMP1405B (Fall 2015)

 

Assignment 6 of 6 Due: Monday, December 7th by 11:30pm For each question in this assignment you will be submitting three files containing source code written in Python 3,

 

that have been compressed into a "zip" file. The Python sources (i.e., the .py files) should be named "a6q1.py"

 

and "a6q2.java". The zip file should be named a6.zip. You will submit your file using cuLearn.

 

A LATE POLICY IS IN EFFECT FOR THIS ASSIGNMENT

 

LATE ASSIGNMENTS WILL BE ACCEPTED FOR 48 HOURS AFTER THE DEADLINE AT A PENALTY OF 2.0% / HOUR

 

You are expected to demonstrate good programming practices at all times (e.g., choosing descriptive variable

 

names, provide comments in your code, etc.) and your code may be penalized if it is poorly written. You are also

 

expected to do the necessary preparatory work (i.e., devising an algorithm) before you start coding.

 

PLEASE NOTE: YOU WILL BE ASKED TO PRESENT EITHER PSEUDOCODE OR A FLOWCHART BEFORE YOU WILL

 

RECEIVE ANY ASSISTANCE FROM THE INSTRUCTOR OR A TEACHING ASSISTANT

 

Question 1 ? Database Utility with Image Support

 

For this question you will write a program with a very simple menu (inside a while loop) that allows users to build

 

and manipulate a database. The different entities of data that you want to store can be anything you wish (but see

 

the note below), and some possible examples are: contacts (storing a name, phone number, email address, and photo)

 

students (storing a name, student number, major, grade, and photo)

 

photos (storing a name, date, list of tages, and the photo itself), etc. Please note that whatever data entity you choose must include at least one piece of data that is an image, that

 

you will load and display with SimpleGraphics. You must also choose some type of unique identifier (a contact

 

name or a student number), and store at least two other pieces of data as well. To clarify, the MINIMUM amount

 

of data would be a unique identifier (also referred to as a key), a photo, and two other pieces of data.

 

Your program must take an object oriented approach to this problem, so you must design a class (including an

 

__init__ method) and have the different pieces of data in your database each be instances of that class. You must

 

also be sure you write accessor and mutator methods and privatize your variables.

 

Once you have defined your class, your program must use a dictionary where the keys are the unique identifiers

 

and the values are instances of your class. Your user must be able to add new elements to the dictionary, remove

 

elements from the dictionary (if they specify the key), look at an individual record from the dictionary (if they

 

provide the key), and view the comple contents of the dictionary (the strings and number can be printed to the

 

console if you wish, but the SimpleGraphics window must be used to draw the image).

 

Your program will be marked on how effectively and efficiently you have implemented your class and manipulated

 

your dictionary.

 

Your should also feel free to embellish your program. Significant embellishments (e.g., the ability to load/save your

 

database to a file or an interface that uses only the mouse and the SimpleGraphics window) may warrant bonus

 

marks - if you have an idea and want to know if it would warrant a bonus, contact your instructor. Question 2 ? Pascal's Triangle in Java

 

For this question you will complete the first question from Assignment 5, in Java instead of Python. The only

 

difference will be that your Java program does not need to worry about "centering" the triangle.

 

1

 

11

 

121

 

1331

 

14641 th th The formula for getting the k number(when you start counting at 0) in the n row is !

 

!(?)! . This calculation is known as the combination. Your solution to this question must be written in Java, and must take the following form - consider the source code

 

provided below to be a "skeleton" onto which you will add the necessary functionality:

 

// don't forget to put your name, student id, comments, and citations!

 

import java.util.Scanner;

 

public class a6q2 {

 

public int factorial(int n) {

 

...

 

}

 

public int combination(int n, int k) {

 

...

 

}

 

public static void main(String args) {

 

a6q2 MYINSTANCE = new a6q2();

 

...

 

}

 

} Here are some important hints to get you started:

 

To reproduce Python's "input" function (with built-in conversion to an integer), you must create a new instance of

 

the Scanner class and call the nextInt() function:

 

// as long as you import java.util.Scanner, this will get an

 

// integer value from the user and store it in the new variable n

 

Scanner in = new Scanner(System.in);

 

int n = in.nextInt(); Since your factorial and combination functions are now methods that belong to your a6q2 class, call them by

 

calling MYINSTANCE.factorial(...) or MYINSTANCE.combination(...)

 

x = MYINSTANCE.combination(n, k); To append an integer on the end of a string (i.e., to build up a String named row, for instance) use the

 

Integer.toString() method as follows:

 

// here is an empty String named row

 

String row;

 

// to which I have now appended the String "123"

 

row = row + " " + Integer.toString(123); Question 2 ? Pascal's Triangle in Java continued Most of the constraints established for your last assignment remain active here - you may not use global variables,

 

import any libraries other than java.util.Scanner, and your solution must not be recursive. If you violate these

 

constraints you will receive a mark of zero.

 

Your program is still expected to begin by asking the user for an integer value to look for in the triangle but you can

 

ignore any error checking or exception handling - assume that you are provided a positive integer. Your program

 

will start printing complete rows of the triangle (without centering them) until it encounters the number entered

 

by the user, at which point it will complete the row and then terminate.

 

Your main method must call MYINSTANCE's combination method and this combination method must call the

 

factorial method. DO NOT WAIT UNTIL THE LAST MINUTE TO ATTEMPT THIS QUESTION

 

THERE WILL BE SOME JAVA QUESTIONS ON YOUR FINAL

 

IF YOU COMPLETED A5Q1, THIS TASK SHOULD BE RELATIVELY EASY

 

YOU ARE NOT BEING ASKED TO DESIGN A NEW ALGORITHM

 

YOU ARE ONLY BEING ASKED TO IMPLEMENT IT AGAIN, IN JAVA

 

IF YOU FIND THAT THIS TASK IS TAKING YOU A VERY LONG TIME,

 

CONSULT YOUR INSTRUCTOR AND/OR TEACHING ASSISTANT ASAP Sample Output (including the syntax for compilation)

 

c:Source>javac a6q2.java

 

c:Source>java a6proofofconcept2

 

What number are you searching for? 6

 

1

 

1

 

1

 

1

 

1 1

 

2 1

 

3 3 1

 

4 6 4 1

 


Solution details:

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
SiteLock

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Sep 13, 2020

EXPERT

Tutor

ANSWER RATING

GET INSTANT HELP/h4>

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now