Implementation of a a queue with a "circular" array or a "regular" array.
(a) "circular" array: consider using the smallest number of fields/variables in a struct/class. List the fields/variables that support the enqueue and dequeue operations in O(1) time in the worst case. Explain why the list is the smallest and the two operations are O(1) time.
(b) "regular" array: explain the worst-case time complexity in big-O for the operations (queue size is at most n).
In: Computer Science
Assume that the following relationships were created in a database. CUSTOMER (CustomerNumber, CustomerLastName, CustomerFirstName, Phone) COURSE (CourseNumber, CourseTitle, TeachingMode, CourseCreationDate, Fee) ENROLLMENT (EnrollmentID, CustomerNumber, CourseNumber, EnrollmentDate, AmountPaid) Legend: Primary Key Foreign Key Possible values TeachingMode: PRE - Presencial, ONL - Online Write the SQL (ORACLE) statements required to complete what is required below. Provide ONE instruction per request / question. Write your answers in the space provided. Identify each answer with the corresponding request / question number. 1. Create the CUSTOMER table include the constraints 2. Create the COURSE table include the constraints 3. Create the ENROLLMENT table include the constraints 4. Create the sequence seqEnroll 5. Insert a row in the CUSTOMER table. 6. Insert a row in the COURSE table. 7. Insert a row in the ENROLLMENT table. The primary key field is a substitute (Surrogate / Artificial) so it will use the sequence you created in statement 4. The transaction must belong to the CUSTOMER you created in # 5 and the COURSE you created in # 6. 8. List customers in ascending alphabetical order by last name. Include the following information in this order: last name, first name and telephone number 9. List all the courses that have the word Pastels in the title. Include all the data in the COURSE table. 10. List all the courses the clients are enrolled in. Include the following data in this order: CustomerNumber, CourseNumber, and AmountPaid. 11. List all courses that started on or before October 1, 2018. Include the following data in this order: CourseDate, CourseNumber, CourseTitle, Fee. 12. Show for each client the total paid for classroom courses and total paid for online courses TeachingMode the total paid by each client. Show courses that are cheaper than the average price Use subquery and functions. 13. List all course information if you have had at least ten clients enrolled in the past twelve months. It must work at any time, the twelve-month period will depend on the date the consultation is run. DO NOT USE SPECIFIC DATES. Use subquery and functions.
In: Computer Science
Hello, I need an expert answer for one of my JAVA homework assignments. I will be providing the instructions for this homework below:
For this lab, you will write the following files:
As you can expect, AbstractDataCalc is an abstract class, that AverageDataCalc, MaximumDataCalc and MinimumDataCalc all inherit.
We will provide the following files to you:
Sample Input / Output
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Given the following CSV file
1,2,3,4,5,6,7 10,20,30,40,50,60 10.1,12.2,13.3,11.1,14.4,15.5
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The output of the provided main is:
Dataset Results (Method: AVERAGE) Row 1: 4.0 Row 2: 35.0 Row 3: 12.8 Dataset Results (Method: MIN) Row 1: 1.0 Row 2: 10.0 Row 3: 10.1 Dataset Results (Method: MAX) Row 1: 7.0 Row 2: 60.0 Row 3: 15.5
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Specifications
You will need to implement the following methods at a minimum. You are free to add additional methods.
AbstractDataCalc
AverageDataCalc
Extends AbstractDataCalc. Will implement the required constructor and abstract methods only.
MaximumDataCalc
Extends AbstractDataCalc. Will implement the required constructor and abstract methods only.
MinimumDataCalc
Extends AbstractDataCalc. Will implement the required constructor and abstract methods only.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CSVReader.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class CSVReader {
private static final char DELIMINATOR =
',';
private Scanner fileScanner;
public CSVReader(String file) {
this(file, true);
}
public CSVReader(String file, boolean
skipHeader) {
try {
fileScanner = new Scanner(new File(file));
if(skipHeader) this.getNext();
}catch (IOException io)
{
System.err.println(io.getMessage());
System.exit(1);
}
}
public List<String> getNext() {
if(hasNext()){
String toSplit = fileScanner.nextLine();
List<String> result = new ArrayList<>();
int start = 0;
boolean inQuotes = false;
for (int current = 0; current < toSplit.length(); current++)
{
if (toSplit.charAt(current) == '\"') { // the char uses the '', but
the \" is a simple "
inQuotes = !inQuotes; // toggle state
}
boolean atLastChar = (current == toSplit.length() - 1);
if (atLastChar) {
result.add(toSplit.substring(start).replace("\"", "")); // remove
the quotes from the quoted item
} else {
if (toSplit.charAt(current) == DELIMINATOR && !inQuotes)
{
result.add(toSplit.substring(start, current).replace("\"",
""));
start = current + 1;
}
}
}
return result;
}
return null;
}
public boolean hasNext() {
return (fileScanner !=
null) && fileScanner.hasNext();
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DataSet.java
import java.util.ArrayList;
import java.util.List;
public class DataSet {
private final List<List<Double>>
data = new ArrayList<>();
public DataSet(String fileName) {
this(new
CSVReader(fileName, false));
}
public DataSet(CSVReader csvReader) {
loadData(csvReader);
}
public int rowCount() {
return
data.size();
}
public List<Double> getRow(int i) {
return
data.get(i);
}
private void loadData(CSVReader file) {
while(file.hasNext())
{
List<Double> dbl = convertToDouble(file.getNext());
if(dbl.size()> 0) {
data.add(dbl);
}
}
}
private List<Double>
convertToDouble(List<String> next) {
List<Double>
dblList = new ArrayList<>(next.size());
for(String item : next)
{
try {
dblList.add(Double.parseDouble(item));
}catch (NumberFormatException ex) {
System.err.println("Number format!");
}
}
return dblList;
}
public String toString() {
return
data.toString();
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Main.java
public class Main {
public static void main(String[] args) {
String testFile =
"sample.csv";
DataSet set = new
DataSet(testFile);
AverageDataCalc averages
= new AverageDataCalc(set);
System.out.println(averages);
MinimumDataCalc minimum
= new MinimumDataCalc(set);
System.out.println(minimum);
MaximumDataCalc max =
new MaximumDataCalc(set);
System.out.println(max);
}
}
In: Computer Science
Create an Employee class having the following functions and
print
the final salary in c++ program.
- getInfo; which takes the salary, number of hours of work per
day
of employee as parameters
- AddSal; which adds $10 to the salary of the employee if it is
less
than $500.
- AddWork; which adds $5 to the salary of the employee if the
number of hours of work per day is more than 6 hours.
In: Computer Science
Having those files please adjust the following tasks.
When the user fills out the registration, all information is inserted into a database table.
When the user signs in, all information is verified from the database table.
You can either create your own table on your machine or use the demo server table for testing. Remember the table name and the fields must be exactly as shown below.
If you are using your own table, you must change the connection info as shown below before uploading to the demo server. Then you must test to make sure it works correctly on the demo server.
The table name will be 'account'.
The fields in the table are:
username - 20 char
password - 50 char
name - 20 char
email - 50 char
Make sure that all field names are the same upper and lowercase letters as shown above.
The password will still be encrypted when stored in the database.
You must insert data into the table using your program. Do not assume anything is on the table.
When creating userids and passwords, use something unique, as your classmates will be sharing the same table.
assignment3
<?php
session_start();
if(isset($_SESSION['userid']))
{
header("Location:home.php");
}
include 'header.php';
?>
<?php
if(isset($_POST["register"]))
{
// collect form data
$first_name=$_POST["first_name"];
$last_name=$_POST["last_name"];
$email=$_POST["email"];
$userid=$_POST["userid"];
$password=$_POST["password"];
$verify_password=$_POST["verify_password"];
if($password===$verify_password) // password verification
{
$hashFormat="$2y$10$"; // set hash
$salt ="iusesomecrazystrings22"; // set salt
$new_salt = $hashFormat . $salt; // concatenate hash and salt
$encrypted_password = crypt($password,$new_salt); // Encrypt the
password
if(file_exists("users.txt")) // check file is exist or not
{
// Open a file for write only and append the data to an existing
file
$myfile = fopen("users.txt", "a");
$mydata=$first_name."|".$last_name."|".$email."|".$userid."|".$encrypted_password."\r\n";
fwrite($myfile, $mydata);
include('send_mail.php');
}
else
{
$myfile = fopen("users.txt", "w"); // Open a file for write
only
fwrite($myfile, "First Name |Last Name | Email| User Id | Password\r\n");
$mydata=$first_name."|".$last_name."|".$email."|".$userid."|".$encrypted_password."\r\n";
fwrite($myfile, $mydata);
include ("send_mail.php");
}
fclose($myfile);
// set the message if password is verified
$register_msg = "The following registration information has been
successfully submitted";
}
else
{
$register_msg = "password not match"; // set the message if
password is not verified
}
}
else
{
$register_msg = "";
}
?>
<html>
<body>
<h1> <?php echo $register_msg; ?> </h1>
<form action="assignment3.php" method="POST"
style="float:left; width:50%;">
<fieldset>
<legend style="text-align: center;">User
Information</legend>
<table style="margin:0px auto;">
<tr>
<td>
<label> First Name</label>
</td>
<td>
<input type="text" name="first_name">
</td>
</tr>
<tr>
<td>
<label> Last Name</label>
</td>
<td>
<input type="text" name="last_name">
</td>
</tr>
<tr>
<td>
<label> Email</label>
</td>
<td>
<input type="email" name="email">
</td>
</tr>
<tr>
<td>
<label> User ID</label>
</td>
<td>
<input type="text" name="userid">
</td>
</tr>
<tr>
<td>
<label> Password</label>
</td>
<td>
<input type="password" name="password"
pattern="(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,12}" title="Must
contain at least one number and one special character, and length
must between 8 to 12 characters">
</td>
</tr>
<tr>
<td>
<label> Verify Password</label>
</td>
<td>
<!--create a password field for Verify Password -->
<input type="password" name="verify_password"
pattern="(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,12}" title="Must
contain at least one number and one special character, and length
must between 8 to 12 characters">
</td>
</tr>
<tr>
<td><input type="submit" name="register"
value="Register"></td>
<td><input type="reset" name="reset"
value="Reset"></td>
</tr>
</table>
</fieldset>
</form>
<form action="home.php" method="POST" style="float:right;
width:50%;">
<fieldset>
<legend style="text-align: center;">Sign
In</legend>
<table style="margin:0px auto;">
<tr>
<td>
<label> User ID</label>
</td>
<td>
<input type="text" name="userid">
</td>
</tr>
<tr>
<td>
<label> Password</label>
</td>
<td>
<input type="password" name="password"
pattern="(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,12}" title="Must
contain at least one number and one special character, and length
must between 8 to 12 characters">
</td>
</tr>
<tr>
<td><input type="submit" name="Submit"
value="Submit"></td>
<td><input type="reset" name="reset"
value="Reset"></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
header.php
<!DOCTYPE html>
<html>
<head>
<title>Assignment3</title>
<link rel="stylesheet" type="text/css" href="main.css"
/>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
</head>
<body>
<header>
<h1>Register for an Account</h1>
</header>
home.php
<?php
session_start();
if(!isset($_POST["Submit"])&&!isset($_SESSION["userid"]))
{
header("Location:assignment3.php");
}
if(isset($_POST['logout']))
{
session_unset();
// destroy the session
session_destroy();
header("Location:assignment2.php");
}
if(isset($_POST["Submit"])) // if Submit parameter exist
{
// collect form data
$userid=$_POST["userid"];
$password=$_POST["password"];
$hashFormat="$2y$10$"; // set hash
$salt ="iusesomecrazystrings22"; // set salt
$new_salt = $hashFormat . $salt; // concatenate hash and salt
$encrypted_password = crypt($password,$new_salt); // Encrypt the password entered by the user
$myfile = file ('./users.txt');
foreach($myfile as $row)
{
$data = explode("|",$row);
// Compare the userid and password to what is in the text file
if($userid===$data[3] &&
$encrypted_password===trim($data[4]))
{
// Set session variables
$_SESSION['userid'] = $data[3]; // Set userid to session
variable
$_SESSION['password'] = $data[4]; // Set password to session
variable
// If password match, set display a welcome message to variable
$msg="Welcome ".$_SESSION['userid'];
}
else
{
// If password do not match, set display this message to
variable
$msg="userid/password combo incorrect please reenter";
}
}
}
else
{
$msg="";
}
?>
<html>
<body>
<h1> <?php echo $msg; ?> </h1>
<?php
if(isset($_SESSION["userid"]))
{
?>
<form action="home.php" method="post">
<input type="submit" value="Sign Out" name="logout">
</form>
<?php
}
?>
</body>
</html>
css file
html {
background-color: #e6f2ff;
}
body {
font-family: Arial, Helvetica, sans-serif;
width: 900px;
margin: 0 auto;
padding: 0 1em;
background-color: white;
border: 1px solid blue;
}
header {
border-bottom: 2px solid black;
padding: .5em 0;
}
header h1 {
color: blue;
}
main {
}
aside {
float: left;
width: 150px;
}
h1 {
font-size: 150%;
margin: 0;
padding: .5em 0 .25em;
}
h2 {
font-size: 120%;
margin: 0;
padding: .75em 0 0;
}
h1, h2 {
color: black;
}
fieldset {
margin: 1em;
padding-top: 1em;
margin-left: 10px;
border: 1px solid blue;
}
label {
float: left;
width: 10em;
text-align: right;
margin-top: .25em;
margin-bottom: .5em;
}
input, select {
margin-left: 0.5em;
margin-bottom: 0.5em;
width: 14em;
}
br {
clear: both;
}
span {
vertical-align: middle;
}
.error {
color: #cc3300;
}
.notice {
color: #cc3300;
font-size: 50%;
text-align: right;
}
In: Computer Science
In C:
You are to create a program to request user input and store the data in an array of structures, and then display the data as requested. The data you are collecting refers to a set of images. The images are OCT images taken of the lining of the bladder. The data you provide will help diagnose the image as cancerous or not, but your code does not need to do that at the moment.
1) Define a global structure that contains the following information:
a) File number (must be >0)
b) Diagnosis number (1-8)
c) Number of layers in the image
d) Maximum average intensity of a single row (should be a float)
e) Width of brightest layer
2) Declare an array of 9 of the structures in #1. This array should be a global variable.
3) Initialize each of the file numbers in the array to -1.
4) Create a loop that will continue asking the user for the above data until the file number 0 is given, or until information has been provided for 9 images.
5) If the user provides a file number less than 0, ask again. Do not ask for further information if the user provides a file number equal to 0.
6) If the user provides a diagnosis number that is not between 1 and 8, ask again.
7) Store the data in the array of structures in the order it is provided.
8) Write a function to display the information for a particular file number. If the file number was not found, nothing is displayed. The function will return a 1 if the file number was found or a 0 if the file number was not in the array.
9) In your main function, after the loop which requests the data, create another loop that will request a file number from the user and then call the function written for #8 to display the data for that file number. This loop will continue until a file number is provided that is not found.
10) In your main function, after the code for #9, add a loop that will display the information for all items stored in the array in order.
In: Computer Science
In: Computer Science
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]
Describe the worst case scenario of quick sort [2 Marks]
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. 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 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
In: Computer Science
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 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 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