× Limited Time Offer ! FLAT 20-40% off - Grab Deal Before It’s Gone. Order Now
Connect With Us
Order Now

 MIS602 Data Modelling and Database Design Assessment Sample

Question

The following case study models a mobile phone company. The company has a number of phones that are sold by staff to various clients. Each phone comes with a plan and each plan has a number of features specific to that plan including:

• a call charge in cents per minute (this does not apply to all plans)
• a plan duration in months
• a break fee if the customer leaves the plan before the end of the plan duration
• a monthly data allowance in gigabytes
Assumptions that are made for the assignment are:
• mobile phones are locked to a plan for the length of the plan duration


Task Instructions

Please read and examine carefully the attached MIS602_Assessment 2_Data Implementation_ Case study and then derive the SQL queries to return the required information. Your focus should be providing the output as meaningful and presentable possible. Please note extra marks will be awarded for presentation and readability of SQL queries.

Please note all the SQL queries should be generated using MySQL server either using MySQL workbench or MySQL Command Line Client.

Provide SQL statements and the query output for the following:

1 Find all the customers whose surname or given name contains the string ‘IND’.

2 Find the total number of female staffs currently working in the company?

3 List all the staff who have resigned after 2018 who were living in any part of CARLTON.

4 List all the staff who gets a pay rate below-average pay rate?

5 Find the supervisor name of the youngest staff.

6 List the most popular plan. If there are more plans (ties), you should display both.

7 List the total number of plans sold by each staff including their name.

8 List the customer id, name, phone number and the details of the staff who sold the plan
to the customer?

9 List the all the staff (staffid and name) who are active not having any supervisor
assigned.

10 How many calls were made in total during the weekends of 2019?

11 The company is considering giving a 10% increase in payrate to all the staff joined before
2012.
(a) How many staff will be affected? Show your SQL query to justify your answer.
(b) What SQL will be needed to update the database to reflect the pay rate increase?

12 Which tower (Towerid, Location) was used by the customer 20006 to make his/her first
call.

13 List all the unique customers (CustomerId, name) having a same colour phone as
CustomerId 20008.

14 List the CustomerID, Customer name, phone number and the total duration customer
was on the phone during the month of August, 2019 from each phone number the
customer owns. Order the list from highest to the lowest duration.

15 i. Create a view that shows the popularity of the plans based on number of plans sold.
ii. Use this view in a query to determine the most popular plan.

16 List all the plans and total number of active phones on each plan.

17 Write an SQL query to join all the seven tables presented in this database taking at least
two columns from each table.

18 List the details of the youngest customer (CustomerId, name, dob, postcode) in postcode
3030 along with total time spent on calls in minutes. Assume call durations are in Seconds.

19 After evaluating all the tables, explain with reasons whether any of the tables violate the
conditions of 3rd Normal Form.

20 In not more 200 words, explain at least two ways to improve this database based on
what we have learned in 1st - 8 th Week.

 

Answer

Q1 Find all the customers whose surname or given name contains the string ‘IND’.
select * from customer where Surname like '%IND%' or Given like '%IND%';

 

Q2 Find the total number of female staffs currently working in the company?
select count(*) as 'Female Staff' from staff where Sex ='F';

 

Q3 List all the staff who have resigned after 2018 who were living in any part of CARLTON.
select * from staff where year(Resigned)>=2018 and Suburb like '%CARLTON%';

 

Q4 List all the staff who gets a pay rate below average pay rate?
select * from staff where RatePerHour <= (select avg(RatePerHour) from staff);

 

Q5 Find the supervisor name of the youngest staff.
select Given from staff order by DOB desc limit 1;

 

Q6 List the most popular plan. If there are more plans (ties), you should display both.
select PlanName, count(*) as CountPlan from mobile group by PlanName order by CountPlan desc limit 1;

 

Q7 List the total number of plans sold by each staff including their name.
select staff.Given, count(*) as 'Number of plans' from mobile left join staff on staff.StaffID = mobile.StaffID group by mobile.StaffID;

 

Q8 List the customer id, name, phone number and the details of the staff who sold the plan to the customer?
select c.CustomerID, c.Given, m.PhoneNumber, s.* from mobile as m left join customer as c on c.CustomerID = m.CustomerID left join staff as s on s.StaffID=m.StaffID;

 

Q9 List the all the staff (staffid and name) who are active not having any supervisor assigned.
Select staffID, Given from staff where SupervisorID=0 and Resigned is null;

 

Q10 How many calls were made in total during the weekends of 2019?
select count(*) as 'Total calls' from calls where weekday(CallDate) in (5,6) and year(CallDate)=2019;

 

Q11a The company is considering giving a 10% increase in payrate to all the staff joined before 2012.
How many staff will be affected? Show your SQL query to justify your answer.
select count(*) as 'Total staff' from staff where year(Joined)<=2012;

 

Q11b What SQL will be needed to update the database to reflect the pay rate increase?
update staff set RatePerHour = RatePerHour*1.10 where year(Joined)<=2012;

 

Q12 Which tower (Towerid, Location) was used by the customer 20006 to make his/her first call.
select t.TowerID, t.Location from mobile as m left join calls as c on c.MobileID=m.MobileID left join connect as cn on c.CallsID=cn.CallsID left join tower as t on t.TowerID=cn.TowerID where CustomerID=20006 order by c.CallDate desc limit 1;


Q13 List all the unique customers (CustomerId, name) having a same colour phone as CustomerId 20008.
select distinct(m.CustomerID), c.Given from mobile as m left join customer as c on c.CustomerID=m.CustomerID where PhoneColour in (select PhoneColour from mobile where CustomerID=20008);

 

Q14 List the CustomerID, Customer name, phone number and the total duration customer was on the phone during the month of August, 2019 from each phone number the customer owns. Order the list from highest to the lowest duration.

select cs.CustomerID,cs.Given,m.PhoneNumber, sum(c.CallDuration) as TotalDuration from calls as c left join mobile as m on m.MobileID=c.MobileID left join customer as cs on cs.CustomerID=m.CustomerID where year(c.CallDate)=2019 and month(c.CallDate)=8 group by m.MobileID order by TotalDuration desc;

 

Q15a Create a view that shows the popularity of the plans based on number of plans sold.
create view popularity_of_plan as select PlanName, count(*) as TotalCount from mobile group by PlanName order by TotalCount desc;

Q15b Use this view in a query to determine the most popular plan.
select * from popularity_of_plan;

 

Q16 List all the plans and total number of active phones on each plan.
select PlanName, count(*) as 'Active phones' from mobile where Cancelled is null group by PlanName;

 

Q17 Write an SQL query to join all the seven tables presented in this database taking at least two columns from each table.
select cst.Given,cst.Sex, m.PhoneNumber, m.PhoneColour, s.RatePerHour,s.Joined, p.PlanName,p.CallCharge, cl.CallDuration,cl.CallTime, cn.ConnectID, cn.TowerID, t.Bandwidth, t.Location from customer as cst left join mobile as m on m.CustomerID=cst.CustomerID left join staff as s on s.StaffID=m.StaffID left join plan as p on p.PlanName=m.PlanName left join calls as cl on cl.MobileID=m.MobileID left join connect as cn on cn.CallsID=cl.CallsID left join tower as t on t.TowerID=cn.TowerID;

 

Q18 List the details of the youngest customer (CustomerId, name, dob, postcode) in postcode 3030 along with total time spent on calls in minutes. Assume call durations are in seconds.

select sum(CallDuration)/60 as 'Time Spend in calls' from calls where MobileID=(select mobile.MobileID from customer left join mobile on customer.CustomerID=mobile.CustomerID where Postcode=3030 order by DOB desc limit 1);

 

Q19 After evaluating all the tables, explain with reasons whether any of the tables violate the conditions of 3rd Normal Form.

Plan table has no unique identity if we want to change the name of the plan, we can’t change that because we are using primary key as plan name. We have to add primary key to plan table and use as foreign keys in other tables like mobile table.

 

Q20 In not more 200 words, explain at least two ways to improve this database based on what we have learned in 1st - 8 th Week.
We can combine surname field and given field as Name field in customer table and staff table. We don’t need date and time data type to DOB field, Joined field and Resigned field, use just date data type for those fields. Validate Phone field and Phonenumber field using only specific character in it. Remove data usage field from calls table. There is no use of data usage.

 

Read More

MITS4002 Object Oriented Software Development Assignment Sample

This assessment item relates to the unit learning outcomes as in the unit descriptors. This checks your understanding about object-oriented software development. This assessment covers the following LOs. LO1 Demonstrate understanding of classes, constructors, objects, data types and instantiation; Convert data types using wrapper methods and objects. LO2 Independently analyse customer requirements and design object-oriented programs using scope, inheritance, and other design techniques; Create classes and objects that access variables and modifier keywords. Develop methods using parameters and return values. LO3 Demonstrate adaptability in building control and loop structures in an object-oriented environment; Demonstrate use of user defined data structures and array manipulation

Project: Comparing Loans

Problem Description:

Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 5% to 8%, with an increment of 1/8. Here is a sample run:

<Output>

Loan Amount: 10000


Design: (Describe the major steps for solving the problem.)

Coding: (Copy and Paste Source Code here. Format your code using Courier 10pts)

Output screenshot: (Paste your output screenshot here)

Testing: (Describe how you test this program)

Submit the following items for assignment help

1. Submit this Word document with solution via LMS (you must submit the program regardless of whether it complete or incomplete, correct or incorrect)
Hint:

1. Can you get the first four rows manually? This will help you understand how to compute the numbers mathematically.

2. Can you write a program to produce the first four rows? This will help you see the pattern.

3. Can you generalize it in a loop to produce all the rows?

4. Finally, format the output correctly.

Solution

Program Design
Step-1 START
Step-2 Initialize required variables
Step-3 Initialize rate = 5%
Step-4 User input: loan amount into amt
Step-5 User input: time in years into yrs
Step-6 If amt or yrs <= 0, print error message and GOTO step 15
Step-7 Set r = rate as backup
Step-8 Display header labels
Step-9 While value of rate < = 8, GOTO steps 10, else GOTO step 15
Step-10 Set rate = r/(100*12) for monthly rate calculation
Step-11 Calculate monthlyPayment as per formula
Step-12 Calculate totalPayment as per formula monthlyPayment*12*yrs
Step-13 Display r, monthlyPayment and totalPayments
Step-14 Increase r by 0.125 and GOTO step-9
Step-15 STOP

Coding

Output Screenshot

Testing

The testing phase of the program was carried out at the very end. At first, the sample data provided with the assignment sample was tested with the same set of inputs. Then, random data was entered to test the output, which was then tallied against the output of trustworthy online Loan Calculators found online.

Firstly, the code was tested against erroneous inputs like negative values for amount and years, or if the user enters 0 for these variables.


Finally, on successfully testing for at least 3-4 sets of data, the testing phase was concluded to be a success. Some screenshots of testing results are presented below.

Read More

MIS501 Principles of Programming Learning Activity Assignment Sample

Qustion

Learning Activity 3.1: Loops

There are a number of activities in this module and you are expected to complete all of these in the labs or in class or in your own time. The first of these is to reproduce any and all of the worked examples in the module content and to review the readings and videos. Then, work your way through these exercises:

1. Write a program to prompt for and read a sequence of non-negative numbers (with a negative number to end input).

Example:

Enter a number (negative to quit): 10.0 Enter a number (negative to quit): 7.5 Enter a number (negative to quit): 3.5 Enter a number (negative to quit): -1

2. Write a program to prompt for and read a sequence of non-negative numbers (with a negative number to end input) and then print the least non- negative input number. If the first number read is negative, print "No numbers.". Round the least number off to one decimal place.
Example:

Enter a number (negative to quit): 10.0

Enter a number (negative to quit): 7.5 Enter a number (negative to quit): 3.5 Enter a number (negative to quit): -1 Least number is: 3.5

3. Write a guessing game where the user has to guess a secret number. After every guess, the program tells the user whether his number was too large or too small. At the end the number of tries needed should be printed. You may count only as one try if the user inputs the same number consecutively. Note that for this question, you need to use a combination of loops and conditional statements.

Please upload one of your answers to the 3.1 discussion forum to discuss with your peers.

 

Learning Activity 3.2: Loops advanced

There are a number of activities in this module and you are expected to complete all of these in the labs or in class or in your own time. The first of these is to reproduce any and all of the worked examples in the module content and to review the readings and videos. Then, work your way through these exercises:

1. Write a program that asks the user for a counter upper bound, and prints the odd numbers between 1 and the user inserted value.

2. Given an asset original price, the percentage with which the asset depreciates every year and the number of years elapsed, write an algorithm that calculates the actual value of the asset at the moment.

Assume that the depreciation percentage is fixed but each year it is calculated on the current actual value of the asset.

3. Given an asset original price, the percentage with which the asset depreciates every year and the actual value of the asset, write an algorithm that calculates the number of years elapsed for the asset to reach this value. Assume that the depreciation percentage is fixed but each year it is calculated on the current actual value of the asset.

4. Write an algorithm that helps investors estimate their bank account balance after a certain number of years. The program should ask the investor to insert the original account balance and the number of years after which they would like to estimate their balance. Note that a Sydney banks offer a fixed yearly interest of 2%.

5. Write an algorithm that helps a frequent traveller employee redeem his expenses. The program should ask the employee about the number of days he has travelled. The program will then repeatedly ask the employee to insert his daily expenses for each day he travelled independently. The program should print out to total sum of the expenses.

Please upload one of your answers to the 3.2 discussion forum to discuss with your peers.

Solution

 

## Thread activity 3.1

## Thread activity 3.2

Read More

COIT20245 Introduction To Programming Assignment Sample

Assignment Brief

For this assignment, you are required to develop a Menu Driven Console Java Program to demonstrate you can use Java constructs including input/output via the console, Java primitive and built-in types, Java defined objects, arrays, selection and looping statements and various other Java commands. Your program must produce the correct results.

The code for the menu and option selection is supplied: GradingSystemMenu.java and is available on the unit website, you must write the underlying code to implement the program. The menu selections are linked to appropriate methods in the given code. Please spend a bit of time looking at the given code to familiarize yourself with it and where you have to complete the code. You will need to write comments in the supplied code as well as your own additions.

Assignment Specification

You have completed the console program for processing grade of students for COIT20245. We are going to extend this application so the students name, student number, marks and grades can be stored in an array of objects, do not use ArrayList.

The program will run via a menu of options, the file GradingSystemMenu.java has been supplied (via the Moodle web site) which supplies the basic functionality of the menu system.


Look at the code supplied and trace the execution and you will see the menu is linked to blank methods (stubs) which you will implement the various choices in the menu.

Student class

First step is to create a class called Student (Student.java).

The Student class will be very simple it will contain seven private instance variables:

o studentName as a String o studentID as a String
o assignmentOneMarks as double o assignmentTwoMarks as double o projectMark as double
o individualTotalMarks as double
o grade as a String

The numeric literal values, like P=50.00, HD=85.00 must be represented as constants.

The following public methods will have to be implemented:

o A default constructor

o A parameterised constructor o Five set methods (mutators) o Five get methods (accessors)

o A method to calculate total marks and return student’s total marks as double – calculateIndividualTotalMarks(). This calculation will be the same as in assignment one.

o A method to calculate grade and return the grade as String – calculateGrade(). This calculation will be the same as in assignment one. Use constants for all numeric literals.

Note: Following basic database principles, calculated values are not usually stored, so in this case we will not store the grade as a instance variable, but use the calculateGrade() method when we want to determine the grade.

GradingSystemMenu class

Once the Student class is implemented and fully tested we can now start to implement the functionality of the menu system.

Data structures

For this assignment we are going to store the student’s name, student number and assessment marks an array of Student objects.

Declare an array of Student objects as an instance variable of GradingSystemMenu class the array should hold ten students.

You will need another instance variable (integer) to keep track of the number of the students being entered and use this for the index into the array of Student objects.


Menu options

1. Enter students name, student number and assessment marks: enterStudentRcord()
You will read in the student’s name, student number and assessment marks as you did in assignment one.


Data validation (you can implement this after you have got the basic functionality implemented) You will need to validate the user input using a validation loop.

The student’s name and student number cannot be blank i.e. not null and the assessments marks needs to be within the range of (0-assessment weighting), the same as assignment one.


When entering record of student’s name, student number and assessments marks, the student have been entered successfully into five local variables you will need to add these values into the student object array, you will also need to increment a counter to keep track of the number of students you have entered and the position in the array of the next student to be entered.

When the maximum number of students record is reached do not attempt to add any more student’s record and give the following error message:

When the student details have been successfully entered, display the details of the student and the charge as follows

Note: For the next two options, display all and statistics you should ensure at least one student’s record has been entered and give an appropriate error message if it there are no students record entered.

Display all student’s name, student number, assessment marks and grade:

displayAllRecordsWithGrade()

When this option is selected display all the records with grade which have been entered so far.

3. Display statistics: display Statistics()

When this option is selected you will display the statistics as per detailed in assignment one document. You can loop through your array of objects to calculate this information.

Remember the welcome and exit messages as per assignment one.

Solution


Menu class Interfaces

GradingSystemMenu app = new GradingSystemMenu();

This line in the main method is used to create an object of the GradingSystemMenu class. Then this class object is used to call the processingGradeingSystem() method. This method is responsible to handle the menu display and menu choice entry from the users for assignment help
int choice = getMenuItem();

This line inside the processingGradeingSystem() method is used to get the user entered menu choice. Also, inside getMenuItem(), the menu is displayed to the user and input is taken using Scanner class object. This choice input is returned to the processingGradeingSystem() method. This repeats in a loop till user enters choice for EXIT. The flowchart below better defines the flow of actions in this context.

Student and GradingSystemMenu class

GradingSystemMenu class uses the enterStudentRcord() method to take entry of all student records and then create a Student object after validation. In order to create the object, the student class constructor is called with user entered values. These objects are then saved inside the students[] array of type Student Class. This array is then used all across the program for various purposes.

Class Diagram



Reflection Report

It took me about 4 to 5 hours in order to complete the programming assignment as a whole. In the first few minutes of this time, I carefully studied the assignment requirements and then downloaded and read through the documented code on the GradingSystemMenu,java file. This helped me to get started with the assignment.

I did not face any noticeable problem with this assignment as the functions were very clearly documented using the todo comments.

Testing Screenshots

Test Invalid menu input



Test Option 2 with no records



Test Option 3 with no records

Test Blank Name and ID



Test Assignment marks range validation



Test Data Record Entry and display



Test Option 2

Test Option 3



Test Option 4

Read More

ITECH1400 Foundation of Programming Assignment Sample

Introduction. In this assignment you are required to develop a program that simulates fishing: There are 6 fish species for assignment help in the river which you may
catch:

Australian Bass (Macquaria Novemaculeata) - commonly less than 4 Kg; excellent eating, when less than 2.5 Kg.
Short Finned Eel (Anguilla Australis)- commonly less than 3 Kg; a good eating fish.
Eel Tailed Catfish (Tandanus Tandanus) - Up to 6.8 Kg; excellent eating, when less than 4 Kg.
Gippsland Perch (Macquaria Colonorum)- commonly less than 10 Kg; excellent eating when up to 6 Kg.
Two more species you should add to this list yourself. Search the internet for the necessary details.

Your program should be based on the following assumptions:
Every second you catch a fish (perfect fishing).
The chances (probabilities) to catch each of these six species are equal.

Weights of fishes of the same species are distributed evenly and range from 0 to the Maximal Weight. The value of Maximal Weight for each of the species is given above. For example, Maximal Weight of Australian Bass is 4 Kg.

Fishing starts with an empty basket which you should implement as a list. If you catch a fish with a weight greater than 500 g or less than the recommended excellent eating maximum, you add it to the basket. Otherwise, release it. For example, only instances of Australian Bass with the weights between 0.5 Kg and 2.5 Kg should be added to the basket.

Stop fishing immediately as soon as the total weight of all the fishes in the basket exceeds 25 Kg.

To generate a random fish and weight, you are supposed to use the “randrange” function from the “random” package. Fishes of different species must be implemented as objects of the corresponding classes. For convenience, all weights appearing in the program body should be integers given in grams e.g. instead of 3 Kg you should use 3000g. However, when printing outputs on the screen you may use kilograms.

2.Develop a module named fish_species (file “fish_species.py”). This module should contain definitions of the following six classes: AustralianBass, ShortFinnedEel, EelTailedCatfish, GippslandPerch + 2 more classes for the species you add yourself.

class AustralianBass should contain the following members:
Variables (Constants):
MAX_WEIGHT = 4000
MAX_EATING_WEIGHT = 2500
NAME = 'Australian Bass'
LATIN_NAME = 'Macquaria Novemaculeata'

The constructor should define and initialise a single attribute named “weight”. The attribute weight must get an integer value between 0 and MAX_WEIGHT.
A method named “is_good_eating”: returns True if the fish’s weight is between 500 g and excellent eating weight (2500 g for Australian Bass).

An overridden (redefined) method “ str ” that returns a nice, readable string representation of a fish object.

3. Develop a module named “fishing” (file “fishing.py”). This module should import the module “fish_species”, so you can use the class definitions from it. In addition, in this module you should define the following functions:

3.1. Function start_fishing().

The function simulates fishing process in the following way:

Every second a random fish is “caught”. I.e., every second the program randomly chooses one of the 6 fish species, then randomly generates a weight within valid range (between 0 and the species’ MAX_WEIGHT), and then creates the corresponding fish object.

If the created fish object is_good_eating, the object is added to the basket (implemented as a list). Otherwise, the fish is released, i.e., is not added to the basket.

Once total weight of fishes in the basket exceeds 25 Kg (25000 g), the basket is returned (fishing ends).

Fishing results should be printed on the screen, one line per second.

3.2. Function print_basket(basket).
The function prints its argument’s (basket’s) content on the screen

3.3. Function plot_basket(basket).
The function plots a bar-chart that shows total weights of each of the species in the basket:

3.4. Functions save_basket(basket, file_name) and load_basket(file_name). In this task you must:
search Python documentation to find out how to use the pickle package in order to save Python objects to files and load the saved objects back to programs.
save_basket(basket, file_name) – using pickle.dump saves the basket to a binary file with the specified name.
load_basket(file_name) – using pickle.load loads a saved object (basket) from the specified file.

Solution

Pseudo code : 2
1. Create class for each species (total 6 class defined)
2. Each class have constant data member max_weight, max_eating_weight
3. Define constructor (init method) to initialize data member
4. Each class have two method is_good_eating and tostring

Fish_species.py
# contents all the classes for fish
class AustrliansBass:
# class variables
MAX_WEIGHT = 4000
MAX_EATING_WEIGHT = 2500
NAME = 'Australian Bass'
LATIN_NAME = 'Macquaria Novemaculeata'
# constructor to initialize weight of fish
def __init__(self, weight):
self.weight = weight

#return true of false based on fish weight
def is_good_eating(self):
return True if self.weight < self.MAX_EATING_WEIGHT else False

# to string method to represent string of any fish
def __str__(self):
return f"{self.NAME} ({self.LATIN_NAME}), weight {self.weight/1000} Kg"

class ShortFinnedEel:
# class variables
MAX_WEIGHT = 2500
MAX_EATING_WEIGHT = 2500
NAME = 'Short Finned Eel'
LATIN_NAME = 'Anguilla Australis'

# constructor to initialize weight of fish
def __init__(self, weight):
self.weight = weight

# return true of false based on fish weight
def is_good_eating(self):
return True if self.weight < self.MAX_EATING_WEIGHT else False

# to string method to represent string of any fish
def __str__(self):
return f"{self.NAME} ({self.LATIN_NAME}), weight {self.weight/1000} Kg"

class EelTailedCatfish:
# class variables
MAX_WEIGHT = 6800
MAX_EATING_WEIGHT = 4000
NAME = 'Eel Tailed Catfish'
LATIN_NAME = 'Tandanus Tandanus'

# constructor to initialize weight of fish
def __init__(self, weight):
self.weight = weight

# return true of false based on fish weight
def is_good_eating(self):
return True if self.weight < self.MAX_EATING_WEIGHT else False

# to string method to represent string of any fish
def __str__(self):
return f"{self.NAME} ({self.LATIN_NAME}), weight {self.weight/1000} Kg"

class GippslandPerch:
# class variables
MAX_WEIGHT = 10000
MAX_EATING_WEIGHT = 6000
NAME = 'Gippsland Perch'
LATIN_NAME = 'Macquaria Colonorum'

# constructor to initialize weight of fish
def __init__(self, weight):
self.weight = weight

# return true of false based on fish weight
def is_good_eating(self):
return True if self.weight < self.MAX_EATING_WEIGHT else False

# to string method to represent string of any fish
def __str__(self):
return f"{self.NAME} ({self.LATIN_NAME}), weight {self.weight/1000} Kg"

class MurrayCod:
# class variables
MAX_WEIGHT = 10000
MAX_EATING_WEIGHT = 5000
NAME = 'Murray Cod'
LATIN_NAME = 'Maccullochella peelii'

# constructor to initialize weight of fish
def __init__(self, weight):
self.weight = weight

# return true of false based on fish weight
def is_good_eating(self):
return True if self.weight < self.MAX_EATING_WEIGHT else False

# to string method to represent string of any fish
def __str__(self):
return f"{self.NAME} ({self.LATIN_NAME}), weight {self.weight/1000} Kg"

class Inanga:
# class variables
MAX_WEIGHT = 3000
MAX_EATING_WEIGHT = 1500
NAME = 'Inanga'
LATIN_NAME = 'Galaxias Maculatus'

# constructor to initialize weight of fish
def __init__(self, weight):
self.weight = weight

# return true of false based on fish weight
def is_good_eating(self):
return True if self.weight <= self.MAX_EATING_WEIGHT else False

# to string method to represent string of any fish
def __str__(self):
return f"{self.NAME} ({self.LATIN_NAME}), weight {self.weight/1000} Kg"

Pseudo code : fishing

1. Import pickle and other necessary library

2. Define fishing()

a. Set Total_weight = 0

b. Declare blank list to store all fish

c. Print “start fishing message”

d. Do until weight is less then 2500

i. Generate random fish species type

ii. Generate random weight for that selected fish

iii. if is_good_eating for selected fish then

1. add to basket

2. show message

3. update total_weight

otherwise release the fish
iv. sleep for 1 second
e. go to step d
f. print “end fishing” and return basket

pseudo code : print_basket

1. for I = 0 to size of basket

2. print the fish details

Pseudo code : plot_basket

1. create a blank dictionary

2. add all six type of fish with value zero

3. iterate all the fish and count total fish for each type

4. use matplotlib library to show bar chart with dictionary key, value pair

5. show the plot

Pseudo code : save_basket

1. open a file with wb option

2. use dump method to store the basket

3. close the file
Pseudo code : load_basket

1. open file with rb option to read binary file

2. call pickle.load method to get all the object of basket

3. close the file
Fishing.py
import pickle
import matplotlib.pyplot as plt
import random
import time
from fish_species import *
def start_fishing():
total_weight = 0
# blank list to store all fish those are good to eat
basket = []
print('Fishing Started!')
while total_weight < 25000:
# select fish class based on random generated number
fish_type = random.randrange(0, 6)
if fish_type == 0:
fish_weight = random.randrange(0, AustrliansBass.MAX_WEIGHT)
fish = AustrliansBass(fish_weight)
elif fish_type == 1:
fish_weight = random.randrange(0, ShortFinnedEel.MAX_WEIGHT)
fish = ShortFinnedEel(fish_weight)
elif fish_type == 2:
fish_weight = random.randrange(0, EelTailedCatfish.MAX_WEIGHT)
fish = EelTailedCatfish(fish_weight)
elif fish_type == 3:
fish_weight = random.randrange(0, GippslandPerch.MAX_WEIGHT)
fish = GippslandPerch(fish_weight)
elif fish_type == 4:
fish_weight = random.randrange(0, MurrayCod.MAX_WEIGHT)
fish = MurrayCod(fish_weight)
else:
fish_weight = random.randrange(0, Inanga.MAX_WEIGHT)
fish = Inanga(fish_weight)
# check wether fish is good to eat
if fish.is_good_eating():
# added to the basket
basket.append(fish)
# calcualte total weight
total_weight += fish_weight
# print message to user
print("t",fish,"- added to the basket.")
else:
print("t",fish, "- released.")
# sleep for 1 second
time.sleep(1)
print('Basket is full. End of fishing session.')
return basket

def print_basket(basket):
print('Contents of the basket: ')
# print all the fish of basket
for fish in basket:
print("t", fish)

def plot_basket(basket):
# create a blank dictionary to count type of fish
fish_data = dict()
# initilaize all fish to zero
fish_data['Australian Bass'] = 0
fish_data['Short Finned Eel'] = 0
fish_data['Eel Tailed Catfish'] = 0
fish_data['Gippsland Perch'] = 0
fish_data['Murray Cod'] = 0
fish_data['Inanga'] = 0

for fish in basket:
# count each fish
fish_data[fish.NAME] += 1
# set figure size
plt.figure(figsize=(10, 5))
# plot the bar chart based on dictionary data
plt.bar(fish_data.keys(), fish_data.values(), color='maroon',width=0.4)
# show bar chart
plt.show()

def save_basket(basket, file_name):
# open file to write object
f = open(file_name, 'wb')
# objects are written
pickle.dump(basket,f)
# close the file
f.close()


def load_basket(file_name):
# open file to read obects
f1 = open(file_name, 'rb')
# stored read object
basket = pickle.load(f1)
f1.close()
# reuturn all fish as a single list
return basket


# start the fishing
basket = start_fishing()
# print all the fish of basket
print_basket(basket)
# plot the fish chart
plot_basket(basket)
# save the fish to myfile
save_basket(basket,"myfile")
# load the myfish file to basket
basket = load_basket("myfile")
# show all fish
print_basket(basket)

Output

Figure 1 - output of 3.1

Outputs of 3.2

Read More

BIS1003 Introduction To Programming Assignment Sample

Assessment 4 Details:

EduWra Company pointed you to develop a program to assist in predicting the customer's preferences. This company sells books online. The program would calculate the average rating for all the books in the dataset and display the highest rated books. We could better predict what a customer might like by considering the customer's actual ratings in the past and how these ratings compare to the ratings given by other customers.
The assessment has two tasks – Task 1: implement the program in Python. Task 2: write a formal report.

Task 1:

Implement the program in Python. Comment on your code as necessary to explain it clearly. Your task for this project is to write a program that takes people's book ratings and makes book recommendations to others using the average rating technique. The program will read customers data from a text file (you find the text file on Canvas site for this unit) that contains sets of three lines about each customer. The first line will have the customer's username, the second line book title, and the third line the rating that is given to the book.

Task 2:

Each group should write a formal report that includes:

- A cove page for your assignment contains the group members' names and contribution percentages (each student must state which parts of the project have been completed). If your name is not on the cover page, you will be given zero.

- Draw system flowchart/s that present the steps of the algorithm required to perform the major system tasks.

- You need to test your program for assignment help by selecting at least three sets of testing data. Provide the results of testing your program with different values and record the testing results using the testing table below.

- Copy the code to your report.

- Take screenshots of the program output.

Solution

 Flowchart

1. Read ratings.txt file



2. Store each bookname from given books



3. Get Rating for each user and corresponding books



4. Get recommendation

Source Code

# Assignment 4 : Applied Project
# Name : Jenil, Rohan, Mayank_group_11
# date : 12/12/2021

# Group No: 11

#this function read all the books information and return
def readBooksName(books):
i = 1
bookNames = []
while True:
if i > len(books):
break
# if bookNames is not founc in the list then only add the bookname
if bookNames.count(books[i].strip()) == 0:
#remove the new line or extra spaces from bookname
bookNames.append(books[i].strip())
#increase the line by 3 to get next book
i = i + 3
return bookNames


#this function will find the rating of each book and store into dictionary
def getRating(books, bookNames):
ratings = {} #create empty dictionary
i = 0
while True:
if i > len(books) - 1: #break loop if reached to last record
break
ratings[books[i].strip()] = [0] * len(bookNames) #create list of zero for each book
i = i + 3 #increase counter by three to read next user name

i = 0
while True:
if i > len(books) - 1:
break
key = books[i].strip()
bookName = books[i+1].strip()
try:
rating = int(books[i+2])
except ValueError:
print('Error: Book rating must be int')
rating = 0
index = bookNames.index(bookName)
#update rating for paricular index book
ratings[key][index] = rating
#increase couter by 3
i = i + 3
return ratings


def calcAverageRating(bookRatings, bookNames):
#create empty list to store avgRatings
avgRatings = []
#get all the ratings of books
values = list(bookRatings.values())
for i in range(len(bookNames)):
sum = 0
count = 0
for ratings in values:
#get the correspoding rating value from values list
sum += ratings[i]
if ratings[i] != 0: #count only not zero value
count += 1
avgRatings.append(sum/count) #calculating avg rating and append to the list
#sorting the avg rating and corresponding bookNames
for i in range(len(avgRatings)):
for j in range(len(avgRatings)):
if avgRatings[i] > avgRatings[j]:
avgRatings[i], avgRatings[j] = avgRatings[j],avgRatings[i]
bookNames[i],bookNames[j] = bookNames[j], bookNames[i]
return avgRatings,bookNames

def showAvgRatings(bookNames,bookAvgRatings ):
for i in range(len(bookNames)):
print('The average ratings for %s is %.2f' % (bookNames[i], bookAvgRatings[i]))

def showRecommendation(bookList):
for book in bookList:
if book[1] != 0:
print('The average ratings for %s is %.2f' % (book[0], book[1]))


def findRecommendation(customerName,bookRatings,bookNames):
givenUser = bookRatings[customerName]
recomendations = []
#retrieve each books and rating values for each user
for key, value in bookRatings.items():
if key != customerName: #take only customer other than given customername
similarity = [] #create empty list to store multiplication of each user
for i in range(len(value)):
similarity.append(value[i] * givenUser[i]) #store the multiplication value
recomendations.append((key, sum(similarity))) #store the sum of similarity value
recomendations.sort(key=lambda x: x[1]) #sorting them by rating
recomendations.reverse() #reverse to get topThree
topThree = recomendations[:3] #getting topthree customer with highest similiarity
bookList = [] #empty list to store booklist
recommend = [0] * len(bookNames) #creating empty list to stroe recommend
for i in range(len(bookNames)):
s = 0
c = 0
for j in topThree:
s = s + bookRatings[j[0]][i] #getting rating value of each user for partiuclar book
if bookRatings[j[0]][i] != 0: #count only for non zero value
c += 1
if c != 0: #find out avg rating where count is non zero
recommend[i] = s / c
bookList.append((bookNames[i], recommend[i])) #append bookname and avg rating to booklist
bookList.sort(key=lambda x: x[1]) #sorting the booklist by rating value
bookList.reverse() #reverse the booklist to get in decending order
return bookList

def main():
try:
fp = open('data3.txt', 'r') #if file not found return with error message
books = fp.readlines()
except IOError:
print('Error: File not found')
return

bookNames = readBooksName(books)
bookRatings = getRating(books, bookNames)
bookAvgRatings, bookNames = calcAverageRating(bookRatings,bookNames)
while True:
print('\n\nWelcome to the EduWra Book Recommendation System.')
print('1: All books average ratings')
print('2: recommend books for a particular user')
print('q: exit the program')
choice = input('\nSelect one of the options above: ')
if choice == 'q':
break
elif choice == '1':
showAvgRatings(bookNames,bookAvgRatings)
elif choice == '2':
customerName = input('\nPlease enter customer name: ')
if customerName in bookRatings:
bookList = findRecommendation(customerName, bookRatings,bookNames)
showRecommendation(bookList)
else:
showAvgRatings(bookNames, bookAvgRatings)


if __name__ == '__main__':
main()

Test Data Table 1

Output details of Test Data 1

Test Data Table 2

Test Data Table 3

Read More

PROG2008 Computational Thinking Assignment 3 Sample

Task Description:

In assignment 2, you have helped a real estate agent to gain some understanding of the market. The agent now wants you to help them set the indicative sale price for their new properties on the market. In this assignment, you will apply your knowledge in data analysis and modelling to build a regression model to predict the indicative sale price of a given property using the previous sale data. In particular, you will

- Apply multivariate analysis and appropriate visualization techniques to analyze the given dataset for the relationship between the sold price and other features of a property.

- Based on the analysis select one feature that can be used to predict the property indicative price. Justify your selection.

- Build a regression model to predict the indicative price from the selected feature.

- Train and validate the model using the given dataset and analyze the prediction power of the model. Discuss the result.

- Distinction students: propose a solution to improve the model accuracy.

- High Distinction students: implement the proposed solution to improve the model. You will use Jupyter Notebook in this assignment to perform the required analyses, visualise data, and show the analysis results.

Getting Help:

This assignment, which is to be completed individually, is your chance to gain an understanding of the fundamental concepts of computer networks which later learning will be based. It is important that you master these concepts yourself. Since you are mastering fundamental skills, you are permitted to work from the examples in the MySCU site or textbook, but you must acknowledge assistance from other textbooks or classmates. In particular, you must not use online material or help from others, as this would prevent you from mastering these concepts. This diagram will help you understand where you can get help:

Solution

Analysis Report

The property sales prediction was done using a python programming language with Anaconda Framework using Jupyter Notebook IDE where the sales prediction dataset was explored at first. The libraries of python used for analysis and visualization were pandas, NumPy, matplotlib, seaborn, and sklearn for importing machine learning algorithms. For Assignment Help -

About data

 

The details about the data are thouroughly discussed in the notebook where each column details has been described about the property and sales.

The data reading was done using pandas where the information about the data was described.
Data processing including the column details, column information of data types, handling missing values and checking null values if present, and summary statistics of the data where the mean, deviation, maximum, count, etc. of the data are described.

Data Visualization

The data visualizations were done using matplotlib and seaborn library which are used for creating attractive and interactive graphs, plots, and charts in python. The different graphs from the data insights are described as communicating about the data containing visuals.

Figure 4 Bedroom description bar chart

The bar chart here describing the bedroom description count where the data containing 45.5% of property with bedrooms and the sales is also depended upon these factors.

Figure 5 Property sales price with bedroom availability



Figure 6 Property sales price with bathroom availability



Figure 7 Property sales price with square fit living availability



Figure 8 Property sales price with floors availability



Figure 9 Property sales price with condition availability

The sale prediction according to the property description is clearly described by the visualizations which describe the descriptive analysis of the data which represents the sales of the property according to the different infrastructure based happened in the past.


Figure 10 Property sales price with space availability



Figure 11 Property sales price with condition availability



Figure 12 Property sales price with grades availability

 

Data Modelling

The machine learning algorithm is applied to the dataset for the predictive analysis where the future prediction based on the descriptive analysis is done to look at whether the models are accurate according to the data and the accuracy of the model describes the predictive analysis rate to predict the property sales in the future.

Figure 13 Regression model

The algorithms are applied to the dataset by training the models by splitting the dataset into train and test split and then the trained and tested values are applied to the algorithms to calculate the score of the applied data.

The predictive analysis score of the linear regression model predicted 100% accuracy whereas the decision tree regression score comes to 99% accuracy which describes the property sales prediction as mostly accurate as assumed.

Read More

Sample Category

Assignment Services