Questions
Write a suitable scenario for Travel Agent System, draw appropriate use case diagrams, derive the classes...

Write a suitable scenario for Travel Agent System, draw appropriate use case diagrams, derive the classes and objects to design and create the class diagram, sequence diagram and activity diagram.

In: Computer Science

Using an example of 6 integer elements, Show how quick sort can be done. [4 Marks]...

  1. Using an example of 6 integer elements,

    1. Show how quick sort can be done. [4 Marks]

  1. Describe the worst case scenario of quick sort [2 Marks]

  2. In your answer at d (i), show what makes quick sort categorized as divide and conquer

[2 marks]

In: Computer Science

Messages comprising seven different characters, A through G, are to be transmitted over a data link....

Messages comprising seven different characters, A through G, are to be transmitted over a data link. Analysis has shown that the related frequency of occurrence of each character is A 0.10, B 0.25, C 0.05, D 0.32, E 0.01, F 0.07, G 0.2
i) Derive the entropy of the messages
ii) Use static Huffman coding to derive a suitable set of codewords.
iii) Derive the average number of bits per codeword for your codeword set to transmit a message and compare this with both the fixed-length binary and ASCII codewords.

iv) State the prefix property of Huffman Coding and hence show that your codeword set derived in the exercise satisfied this.
v) Derive a flowchart for an algorithm to decode a received bit string encoded using your codeword set.
vi) Give an example of the decoding operation assuming the received bit string comprises a mix of seven characters

In: Computer Science

####################################################################### ##################################### ###############python################# # RQ1 def merge(dict1, dict2): """Merges two Dictionaries. Returns a new dictionary that...

#######################################################################
#####################################
###############python#################

# RQ1
def merge(dict1, dict2):
    """Merges two Dictionaries. Returns a new dictionary that combines both. You may assume all keys are unique.

    >>> new =  merge({1: 'one', 3:'three', 5:'five'}, {2: 'two', 4: 'four'})
    >>> new == {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five'}
    True
    """
    "*** YOUR CODE HERE ***"


# RQ2
def counter(message):
    """ Returns a dictionary where the keys are the words in the message, and each
    key is mapped (has associated value) equal 
    to the number of times the word appears in the message.
    >>> x = counter('to be or not to be')
    >>> x['to']
    2
    >>> x['be']
    2
    >>> x['not']
    1
    >>> y = counter('run forrest run')
    >>> y['run']
    2
    >>> y['forrest']
    1
    """
    "*** YOUR CODE HERE ***"

In: Computer Science

Semester 2019 Java Programming Project 3: Loops, Strings, and Character Methods Having a secure password is...

Semester 2019
Java Programming Project 3: Loops, Strings, and Character Methods


Having a secure password is a very important practice, particularly when much of our personal information is stored online.

Please write a program that validates a new password, following these 4 rules:

The password must be at least 8 characters long.
The password must have at least one upper case letter.
The password must have at least one lower case letter.
The password must have at least one digit.
1) Your program should ask for a password, and then check first to see if the password is valid (i.e., conforms to the specifications outlined above.) If not, the program should allow the user to continue to enter passwords until s/he enters a valid password.

2) Then your program should confirm the password by requesting that the user enter the password again, and verify that the two match. If they don't match, allow the user to try it again (for a total of 3 tries only).

You will need a minimum of two methods, one to confirm the two passwords, and at least one (or more) to check to see if the password meets the 4 required specifications outlined above.

Carefully examine and follow ALL the program requirements. Make sure you use prologue comments for your program, including prologue comments for each of your methods. You will find both the Java String methods as well as the Character Class Methods immensely helpful for this Lab. Please use comments as well for any part of your code that may not be self-explanatory or may require some additional documentation.

You will find both the Java String methods as well as the Character Class Methods immensely helpful for this Lab.

SUBMISSION GUIDELINES:

1) Please write and submit an algorithm (in class) to help you with the design phase of this lab.

2) Submit a hard copy of your Java program (in class).

3) Attach your java program online in the Assignments tool. Go to Assessments-->Assignment --> Java Programming Project 3.

4) Submit a hard copy of program output or output screen shots of your program in action illustrating its functionality. You should show at least 3 program runs.


In: Computer Science

One of your friends has an awful writing style: he almost never starts a message with...

  1. One of your friends has an awful writing style: he almost never starts a message with a capital letter, but adds uppercase letters in random places throughout the message. It makes chatting with him very difficult for you, so you decided to write a plugin that will change each message received from your friend into a more readable form.

Implement a function that will change the very first symbol of the given message to uppercase, and make all the other letters lowercase.

2. Implement a function that will compute the area of a triangle.

In: Computer Science

You have been assigned to a development team that is building software that will be used...

You have been assigned to a development team that is building software that will be used to control the operations of a bicycle rental store. A rental store has a limited number of vehicles that can be managed. A bicycle rental store must maintain information about how many vehicles are available for rental. The bicycle rental store must provide publicly available methods to allow vehicles to be added and removed from it. The rental store should also provide publicly available methods that reports its capacity. An attempt to add or remove the vehicle other than it’s capacity should print the message letting user know that he/she can’t add or delete the vehicle (Hint: use “if” condition to check the number of vehicles. They shouldn’t be more that 5/5 each to add and less than 1 to delete). At the moment there are two distinct types of vehicles: bicycle and quadricycle (four-wheel bicycle). Every vehicle has a company code, a fun name, number of wheels and a rental price. The bicycle has two wheels whereas quadricycle has four. Define the Java classes that are required to implement the functionality that is described above. Be sure to use object-oriented principles in your Java code. Hints • Vehicle class, Bicycle class, Quadricycle class, RentalStore class. • Bicycle class and Quadricycle class inherits extends from Vehicle class • RentalStore class will have methods to show the total number of vehicles, add/delete Bicycle and add/delete Quadricycle • Rental class should have ArrayList • In general every class should have attributes, constructor and it’s methods. • Besides RentalStore class, all other classes should have toString() method . • Create TestClass that have Main() method. Bicycles: company code 0001, a fun name ( your choice), number of wheels : 2 and a rental price 150 company code 0002, a fun name ( your choice), number of wheels : 2 and a rental price 110 company code 0003, a fun name ( your choice), number of wheels : 2 and a rental price 50 company code 0004, a fun name ( your choice), number of wheels : 2 and a rental price 250 company code 0005, a fun name ( your choice), number of wheels : 2 and a rental price 90 quadricycle : company code 0011, a fun name ( your choice), number of wheels : 4 and a rental price 250 company code 0012, a fun name ( your choice), number of wheels : 4 and a rental price 110 company code 0013, a fun name ( your choice), number of wheels : 4 and a rental price 210 company code 0014, a fun name ( your choice), number of wheels : 4 and a rental price 210 company code 0015, a fun name ( your choice), number of wheels : 4 and a rental price 190 For this scenario, we will have 5 bicycles and 5 quadricycles (total of 10 vehicles). Add all those vehicles to an ArrayList. Find bicycles with price less than $100 and delete all of them. Find quadricycles with price less than $200 and delete all of them. At last, show to total number of remaining vehicles with their details.

In: Computer Science

Project Description In this project you will build a car configuration application in six units. Each...

Project Description

In this project you will build a car configuration application in six units. Each unit provides learning opportunities in Object Oriented Design. You are expected to document these lessons and apply them in the next unit. You will notice that the design guidance will taper off as you progress through units in Project 1. You will be expected to design on your own.

Project 1 - Unit 1

In this project you will build a Car Configuration Application using Java. In this unit you will develop a “reference” base object model, read a text file to build the reference base object model and archive it using Serialization.

I would like you to start with a proof of concept – so we will first build the underlying object using normal Java Classes and Inner Classes.

For our proof of concept please consider the following requirements:

We will build Ford's Focus Wagon ZTW model with these options:

  • ● Color - Fort Knox Gold Clearcoat Metallic, Liquid Grey Clearcoat Metallic, Infra-Red Clearcoat, Grabber Green Clearcoat Metallic, Sangria Red Clearcoat Metallic, French Blue Clearcoat Metallic, Twilight Blue Clearcoat Metallic, CD Silver Clearcoat Metallic, Pitch Black Clearcoat, Cloud 9 White Clearcoat

  • ● Transmission - automatic or manual

  • ● Brakes/Traction Control - Standard, ABS, or ABS with Advance Trac

  • ● Side Impact Airbags - present or not present

  • ● Power Moonroof - present or not present
    Configuration options and cost data:

Base Price

$18,445

Color

No additional cost

Transmission

0 for automatic, $­815 for standard (this is a "negative option")

Brakes/Traction Control

$0 for standard, $400 for ABS, $1625 for ABS with Advance Trac

Side Impact Air Bags

$0 for none, $350 if selected

Power Moonroof

$0 for none, $595 if selected

Your Deliverable:

Design and code classes for these requirements and write a driver program to instantiate a Ford Wagon ZTW object and write it to a file. Test your code with a couple of instances of Forward Wagon ZTW.

Use the following driver (or something similar) for testing entire project.

class Driver {

public static void main(String [] args) {

//Build Automobile Object from a file.

Automobile FordZTW = (Some instance method in a class of Util package).readFile("FordZTW.txt");

//Print attributes before serialization

FordZTW.print();

//Serialize the object

Lab1.autoutil.FileIO.serializeAuto(FordZTW);

//Deserialize the object and read it into memory.

Automobile newFordZTW = Lab1.autoutil.FileIO.DeserializeAuto("auto.ser"); //Print new attributes.

newFordZTW.print();

}

}


In: Computer Science

Project Description In this project you will build a car configuration application in six units. Each...

Project Description

In this project you will build a car configuration application in six units. Each unit provides learning opportunities in Object Oriented Design. You are expected to document these lessons and apply them in the next unit. You will notice that the design guidance will taper off as you progress through units in Project 1. You will be expected to design on your own.

Project 1 - Unit 1

In this project you will build a Car Configuration Application using Java. In this unit you will develop a “reference” base object model, read a text file to build the reference base object model and archive it using Serialization.

I would like you to start with a proof of concept – so we will first build the underlying object using normal Java Classes and Inner Classes.

For our proof of concept please consider the following requirements:

We will build Ford's Focus Wagon ZTW model with these options:

  • ● Color - Fort Knox Gold Clearcoat Metallic, Liquid Grey Clearcoat Metallic, Infra-Red Clearcoat, Grabber Green Clearcoat Metallic, Sangria Red Clearcoat Metallic, French Blue Clearcoat Metallic, Twilight Blue Clearcoat Metallic, CD Silver Clearcoat Metallic, Pitch Black Clearcoat, Cloud 9 White Clearcoat

  • ● Transmission - automatic or manual

  • ● Brakes/Traction Control - Standard, ABS, or ABS with Advance Trac

  • ● Side Impact Airbags - present or not present

  • ● Power Moonroof - present or not present
    Configuration options and cost data:

Base Price

$18,445

Color

No additional cost

Transmission

0 for automatic, $­815 for standard (this is a "negative option")

Brakes/Traction Control

$0 for standard, $400 for ABS, $1625 for ABS with Advance Trac

Side Impact Air Bags

$0 for none, $350 if selected

Power Moonroof

$0 for none, $595 if selected

Your Deliverable:

Design and code classes for these requirements and write a driver program to instantiate a Ford Wagon ZTW object and write it to a file. Test your code with a couple of instances of Forward Wagon ZTW.

Use the following driver (or something similar) for testing entire project.

class Driver {

public static void main(String [] args) {

//Build Automobile Object from a file.

Automobile FordZTW = (Some instance method in a class of Util package).readFile("FordZTW.txt");

//Print attributes before serialization

FordZTW.print();

//Serialize the object

Lab1.autoutil.FileIO.serializeAuto(FordZTW);

//Deserialize the object and read it into memory.

Automobile newFordZTW = Lab1.autoutil.FileIO.DeserializeAuto("auto.ser"); //Print new attributes.

newFordZTW.print();

}

}


In: Computer Science

home / study / engineering / computer science / questions and answers / i have a...

home / study / engineering / computer science / questions and answers / i have a c++ question, its already posted on here ... Question: I have a c++ question, its already posted on here ... Bookmark I have a c++ question, its already posted on here but the answer given is way too complex and i dont understand it... its only the first month of c++ so please use the basic code... thank you.

Assume that ax^2 + bx + c = 0. We can now use the quadratic equation to find the value(s) of x. 1. Write a program that generates 3 seeded random integers ranging from -5 to 5 for the values of a, b and c. (You need to seed the random numbers) 2. If a is equal to 0, output “We cannot divide by 0” and do nothing. This is the end of the program. 3. If a is NOT equal to 0, then do the following: 3-1) If b^2– 4ac is positive, then you should output 2 possible values for x based on above equation 3-2) If b^2– 4ac is 0, then you should output 1 value for x. 3-3) Otherwise, you should output “No solution for x” Run the program five times to test. Make sure for each run the value for a, b, c changes.

In: Computer Science

Project Description In this project you will build a car configuration application in six units. Each...

Project Description

In this project you will build a car configuration application in six units. Each unit provides learning opportunities in Object Oriented Design. You are expected to document these lessons and apply them in the next unit. You will notice that the design guidance will taper off as you progress through units in Project 1. You will be expected to design on your own.

Project 1 - Unit 1

In this project you will build a Car Configuration Application using Java. In this unit you will develop a “reference” base object model, read a text file to build the reference base object model and archive it using Serialization.

I would like you to start with a proof of concept – so we will first build the underlying object using normal Java Classes and Inner Classes.

For our proof of concept please consider the following requirements:

We will build Ford's Focus Wagon ZTW model with these options:

  • ● Color - Fort Knox Gold Clearcoat Metallic, Liquid Grey Clearcoat Metallic, Infra-Red Clearcoat, Grabber Green Clearcoat Metallic, Sangria Red Clearcoat Metallic, French Blue Clearcoat Metallic, Twilight Blue Clearcoat Metallic, CD Silver Clearcoat Metallic, Pitch Black Clearcoat, Cloud 9 White Clearcoat

  • ● Transmission - automatic or manual

  • ● Brakes/Traction Control - Standard, ABS, or ABS with Advance Trac

  • ● Side Impact Airbags - present or not present

  • ● Power Moonroof - present or not present
    Configuration options and cost data:

Base Price

$18,445

Color

No additional cost

Transmission

0 for automatic, $­815 for standard (this is a "negative option")

Brakes/Traction Control

$0 for standard, $400 for ABS, $1625 for ABS with Advance Trac

Side Impact Air Bags

$0 for none, $350 if selected

Power Moonroof

$0 for none, $595 if selected

Your Deliverable:

Design and code classes for these requirements and write a driver program to instantiate a Ford Wagon ZTW object and write it to a file. Test your code with a couple of instances of Forward Wagon ZTW.

Use the following driver (or something similar) for testing entire project.

class Driver {

public static void main(String [] args) {

//Build Automobile Object from a file.

Automobile FordZTW = (Some instance method in a class of Util package).readFile("FordZTW.txt");

//Print attributes before serialization

FordZTW.print();

//Serialize the object

Lab1.autoutil.FileIO.serializeAuto(FordZTW);

//Deserialize the object and read it into memory.

Automobile newFordZTW = Lab1.autoutil.FileIO.DeserializeAuto("auto.ser"); //Print new attributes.

newFordZTW.print();

}

}


In: Computer Science

• In this script, write MATLAB code to create an array A of size 100 ×...

• In this script, write MATLAB code to create an array A of size 100 × 3. The first column should contain random numbers between 0 and 10. The second column should also contain random numbers between 0 and 10. The third column should contain random integers between 20 and 50. The first two columns represent the x and y coordinates of a map, respectively. The third column represents the height of buildings. For example, if the first row of A is equal to [3.4 4.5 28], this means that there is a building of height 28 at location (3.4, 4.5) in the map. Because array A has 100 rows, there will be 100 buildings located at random points in the map. • Then, save array A in a file using the MATLAB function save. You may select the name of the file yourselves. • Then, plot the first column of array A vs the second column of array A, using ‘*’ (i.e., the points will be plotted as stars) so that you can see the 100 locations of the buildings. • Finally, after you save the array, clear all variables by placing a clear all at the end of the MATLAB script. • In this script, write MATLAB code to first read the file that you saved in Part A. To read the file, use the MATLAB function load. After you read the file, array A should again become available to you. • Then, write code to move the data from array A to a cell array C of size 10 × 10 in the following way: ◦ The element C{1,1} in C should be an array containing all building heights with x coordinates between 0 and 1 AND y coordinates between 0 and 1. ◦ The element C{2,1} in C should be an array containing all building heights with x coordinates between 1 and 2 AND y coordinates between 0 and 1. ◦ The element C{1,2} in C should be an array containing all building heights with x coordinates between 0 and 1 AND y coordinates between 1 and 2. ◦ The element C{2,2} in C should be an array containing all building heights with x coordinates between 1 and 2 AND y coordinates between 1 and 2. ◦ The element C{3,2} in C should be an array containing all building heights with x coordinates between 2 and 3 AND y coordinates between 1 and 2.

In: Computer Science

QUESTION 2 You are developing an online quiz web application and you have been asked to...

QUESTION 2 You are developing an online quiz web application and you have been asked to design a JSON file for creating a TestBank. You need to design the JSON file for storing some multiple choice questions/answers. Here is an example of sample data which you need to convert it into JSON Q) 5 + 7 * 2 = ? a) 14 b) 12 c) 24 d) 19 ANS: d Answer the following questions: 1) How do you design the JSON file? Create the JSON file (for 5 sample test-questions) and validate it. 2) Develop a jQuery program which displays all questions, their multiple options, and the right answer.

In: Computer Science

Using the Accra Institute Technology Wifi for Students as an example, explain the challenge(s) you face...

Using the Accra Institute Technology Wifi for Students as an example, explain the challenge(s) you face while accessing it, explain why the challenge(s) exist(s) and explain what you think could be done to fix the challenge(s).

In: Computer Science

Using Java, write code as follows: Create an interface called Items. It should define at least...

Using Java, write code as follows:

  1. Create an interface called Items. It should define at least the following methods:
    1. public void add( Object item ) - adds a single object to the collection.
    2. public Object get( int index ) - returns an item at a specific index.
    3. public int size() - returns the number of items stored in the collection.
    4. public void addAll( Object[] items ) - adds all of the elements in the array to the collection.
  2. Write a class called AbstractItems that implements the Items interface. It should provide concrete implementations of at least the following methods:
    1. public void addAll( Object[] items ) - This should simply loop and call the add method for each item in the array.
    2. public String toString() - returns a string that lists all of the items on a single line. For example, if the collection contained the strings “abc”,“123”, and “cat” the toString method should return something like “abc 123 cat”. This method should use a loop and call the get method.
  3. Create a class called ArrayOfItems that extends AbstractItems.
    1. Create a constructor that takes an integer parameter called size and use it to create an Object array of that size to hold your items.
    2. Use the array to implement the remaining abstract methods inherited from the Items class: add, size, and get. Note that size should return the number of items that have been added to the array, not the size of the array. In other words, if your initial array is large enough to hold 10 items, but only 2 items have been added, your size method should return 2, not 10. Once the array is full, the add method should ignore additional values.
  4. You should include a main method to test the addAll and toString methods as well as the add, get, and size methods.
  5. Create a class called Node. A Node has two instance variables.
    1. An Object named item.
    2. A reference to another Node called next.

Create the appropriate accessors and mutators for both variables.

  1. Create a class called ListOfItems that extends AbstractItems. This new class will us the Node created previously. The class will need three instance variables:
    1. A Node called head.
    2. A Node called tail.
    3. An int called size.

When a ListOfItems is created, create a new Node and set both the head and the tail to refer to it. The first time that the “add” method is called, add the Object to the head node and increment size from 0 to 1 Each time add is called after that, follow this algorithm:

  1. Create a new Node.
  2. Add the Object to the new Node. using the setItem method.
  3. Use the setNext mutator on the current tail to point to the new Node.
  4. Change the tail to point to the new Node.
  5. Increment size.

Also provide an implementation for the get method. This will require you to start at the head and use the getNext method to count the appropriate number of nodes in the list before returning the item at the specified index using its getItem method.

  1. Create a class called ItemsTest with two methods:
    1. public static void testItems(Items items) - this method should thoroughly test all methods of the Items interface (add, addAll, get, size, toString). The Items instance should be printed to standard output (using its toString method) each time the contents are changed.
  2. public static void main(String[] args) - Your main method should create at least one instance of each of the implementation classes and call the testItems method. You must show that your ArrayOfItems ignores values after the array is full.

In: Computer Science