HTML/CSS/JavaScript
Create a page that converts 4 different measurements (i.e. length, volume, area, distance) to either Imperial or Metric values. When a value is entered into one of the fields, the converted amount is displayed in the other corresponding field.
Example:
Converting between litres and gallons. If you enter 25 for gallons, the value of 113.50 litres should be displayed.
Converting between gallons and litres. If you enter 75 litres, the value of 16.52 gallons should be displayed. (Note, 1 Imperial gallon is 4.54 litres)
Example:
Converting between metres and feet. If you enter 125 for feet, the value of 38.10 metres should be displayed.
Example:
Converting square metres to feet. If you enter 95 for square metres, the value of 1022.57 square feet should be displayed.
Your page will require JavaScript ‘event handlers’ that will respond to changes in the number field and call the correct functions. Your answers should display to 2 significant digits. Your page must use CSS to create an interesting and pleasing interface
In: Computer Science
2- Plain Text (Message):
a) JERSEY
b) CALIFORNIA
Key: CSEC
Scheme: Vigenere Cipher
Cipher Text:
In: Computer Science
A Deque is an ADT which allows efficient (O(1)) insertion and removal at either end of the structure. Typically, a deque is implemented with a doubly-linked list (DLL), and has the following API:
addFront(data) # adds element to head of the DLL removeFront() # removes (and returns) element from head of the DLL addRear(data) # adds element to the tail of the DLL removeRear() # removes (and returns) element from the tail of the DLL
Which of the Deque operations could be used to implement the Queue ADT enqueue and dequeue methods, respectively:
A deque cannot be used to implement a queue
addFront, removeFront
addFront, removeRear
addRear, removeFront
(addFront, removeRear) or (addRear, removeFront)
addRear, removeRear
(addFront, removeFront) or (addRear, removeRear)
In: Computer Science
Discuss the security features in SNMPV3 that SNMPV1 and SNMPV2 do not provide
In: Computer Science
SQL Trigger problem
When attemptiing to Create or Replace a trigger I get the error "sql warning trigger created with compilation errors".
Trigger:
CREATE OR REPLACE TRIGGER Late_Fees
after UPDATE
ON InventoryItem
FOR EACH ROW
DECLARE
late_fee number;
num_days number;
BEGIN
num_days:= to_date(:old.ReturnDate)-TO_DATE(:old.DateDue);
select IntValue into late_fee from ApplicationSettings where
Setting='Daily Late Fee';
:new.fee := (late_fee)*(num_days);
END;
/
commit;
Table:
create table Rental(
INVID int Primary key,
LoanDate date,
PatronID int,
DueDate date,
ReturnDate date,
constraint PatronID_FK Foreign key (PatronID) references
Patrons(PatronID));
Test Input:
insert into rental
values ('1345', '2020-02-20', '000', '2020-02-27',
'2020-02-22');
insert into rental
values ('1345', '2020-04-10', '000', '2020-04-17',
'2020-04-17');
insert into rental
values ('1234', '2020-02-20', '000', '2020-02-27',
'2020-02-22');
insert into rental
values ('1245', '2020-02-20', '000', '2020-02-27',
'2020-02-22');
insert into rental
values ('1345', '2020-08-14', '0001', '2020-08-21',
'2020-08-20');
insert into rental
values ('1265', '2020-09-01', '0001', '2020-09-08',
'2020-09-10');
In: Computer Science
A palindrome is a string that reads the same forward and backward, for example, radar, toot, and madam. Your task is to construct a python algorithm to receive as input a string of characters and check whether it is a palindrome using a stack and a queue. Your ADTs contains the following methods:
Queue
Stack
Please explain the solution with details and document the code.
In: Computer Science
Let A[1 · · · n] be an array of n elements and B[1 · · · m] an array of m elements. We assume that m ≤ n. Note that neither A nor B is sorted. The problem is to compute the number of elements of A that are smaller than B[i] for each element B[i] with 1 ≤ i ≤ m.
For example, let A be {30, 20, 100, 60, 90, 10, 40, 50, 80, 70} of ten elements. Let B be {60, 35, 73} of three elements. Then, your answer should be the following: for 60, return 5 (because there are 5 numbers in A smaller than 60); for 35, return 3; for 73, return 7.
(a) Design an O(mn) time algorithm for the problem. (10 points)
(b) Improve your algorithm to O(n log
m) time. (20 points)
Hint: Use the divide and conquer technique. Since m ≤
n, you cannot sort the array A because that would
take O(n log n) time, which is not
O(n log m) as m may be much smaller than
n.
Note: For this problem, you need to describe the main idea of your algorithms and briefly analyze their time complexities. You will receive the full 30 points if you give an O(n log m) time algorithm directly for (b) without giving any algorithm for (a).
In: Computer Science
Remember that great app you wrote for Yogurt Yummies (Lab 10-2). They want you to enhance the C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Now they need to process multiple sales. Do not change any logic for handling a single sale. Make the following enhancements:
● Add "v2" to the application output header and close.
● Declare and initialize overall totals including:
ü Number of sales.
ü Overall number of yogurts sold.
ü Overall sale amount after discount.
ü Overall tax paid.
ü Overall sale total.
● Enclose the logic for a single sale with a sentinel loop that continues to process sales until the user enters 'n'.
● After calculating sale totals, update overall totals.
● When the user enters the sentinel value ('n'), print overall totals using formatted output manipulators (setw, left/right). Run the program with invalid and valid inputs, and at least three sales. The output should look like this:
Welcome to Yogurt Yummies, v2
-----------------------------
Enter another yogurt purchase (y/n)? y
Sale 1
----------------------------------------
Enter the number of yogurts purchased (1-9): 11
Error: '11' is an invalid number of yogurts.
Enter the number of yogurts purchased (1-9): 2
Enter the percentage discount (0-20): 22
Error: '22.00' is an invalid percentage discount.
Enter the percentage discount (0-20): 4
Yogurts: 2
Yogurt cost ($): 3.50
Discount (%): 4.00
Subtotal ($): 7.00
Total after discount ($): 6.72
Tax ($): 0.40
Total ($): 7.12
Enter another yogurt purchase (y/n)? y
Sale 2
----------------------------------------
Enter the number of yogurts purchased (1-9): 5
Enter the percentage discount (0-20): 10
Yogurts: 5
Yogurt cost ($): 3.50
Discount (%): 10.00
Subtotal ($): 17.50
Total after discount ($): 15.75
Tax ($): 0.94
Total ($): 16.70
Enter another yogurt purchase (y/n)? y
Sale 3
----------------------------------------
Enter the number of yogurts purchased (1-9): 7
Enter the percentage discount (0-20): 20
Yogurts: 7
Yogurt cost ($): 3.50
Discount (%): 20.00
Subtotal ($): 24.50
Total after discount ($): 19.60
Tax ($): 1.18
Total ($): 20.78
Enter another yogurt purchase (y/n)? n
Overall totals
========================================
Sales: 3
Yogurts: 14
Total after discount ($): 42.07
Tax ($): 2.52
Total ($): 44.59
End of Yogurt Yummies, v2
This is from yogurt Yummies V1
Welcome to Yogurt Yummies
-------------------------
Enter the number of yogurts purchased (1-9): 12
Error: '12' is an invalid number of yogurts.
Enter the number of yogurts purchased (1-9): 4
Enter the percentage discount (0-20): 30
Error: '30.00' is an invalid percentage discount.
Enter the percentage discount (0-20): 10
Yogurts: 4
Yogurt cost ($): 3.50
Discount (%): 10.00
Subtotal ($): 14.00
Total after discount ($): 12.60
Tax ($): 0.76
Total ($): 13.36
End of Yogurt Yummies
In: Computer Science
What steps would my computer have to go through to resolve the name cobalamin.csclub.uwaterloo.ca to an IPv4 using a full recursive query?
In: Computer Science
The following SinglyLinkedList class is available:
class SinglyLinkedList: class _Node: """Lightweight, nonpublic class for storing a singly linked node.""" __slots__ = 'element', 'next' # streamline memory usage def __init__(self, element, next): # initialize node's fields self.element = element # reference to user's element self.next = next # reference to next node def __init__(self): # initialize list's fields self._head = None # head references to None def printList(self, label): print(label, end=' ') curr = self._head while curr != None: print(curr.element, end=" -> ") curr = curr.next print("/") ######################################################### # Only this method is required for your solution def computeStats(self): # Your code goes here ######################################################### def main(): # Create a list object for testing purpose sList = SinglyLinkedList() # Create list 2 -> 4 -> -1 -> 8 -> -5 sList._head = sList._Node(2, sList._Node(4, sList._Node(-1, sList._Node(8, sList._Node(-5, None))))) sList.printList("before:") # Call computeStats method sList.computeStats() # And see if it worked! sList.printList("after :") if __name__=="__main__": main()
Assume you have a singly-linked list of integers, some positive and some negative. Write a Python method that traverses this list to calculate both the average and the count (ie, number) of the odd values only. Once calculated, add the average to a new node at the front of the list, and the count to a new node at the end of the list. You may assume that the list will always contain at least one odd value.
Your method will be have the following method signature:
def computeStats(self):
You may use only the SinglyLinkedList class; no other methods (like size(), etc) are available.
For example, if the list initially contains:
2 → 4 → -1 → 8 → -5
the resulting list will contain:
-3.0 → 2 → 4 → -1 → 8 → -5 → 2
In: Computer Science
Explain in detail how is Machine Learning part of face mask detection?
In: Computer Science
Each new term in the Fibonacci sequence is generated by adding
the previous two terms. By starting with 1 and 2, the first 10
terms will be:
1,2,3,5,8,13,21,34,55,89,...
By considering the terms in the Fibonacci sequence whose values do
not exceed 1000, find the sum of
the all the terms up to 300.
In: Computer Science
How do i remove the decimals out of the output? Do I need to int a new value, or use Math.round?
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
double numbers[] = new double[5];
inputArray(numbers);
maxNumber(numbers);
minNumber(numbers);
}
public static void inputArray( double[] numbers) {
Scanner in = new Scanner(System.in);
for(int i = 0; i < numbers.length; i++) {
numbers[i] = in.nextDouble();
}
}
public static void maxNumber(double[] numbers) {
double maxNum = numbers[0];
for(int i = 0; i < numbers.length; i++) {
if(numbers[i] > maxNum ) {
maxNum = numbers[i];
}
}
System.out.println("Max: "+maxNum);
}
public static void minNumber(double[] numbers) {
double minNum = numbers[0];
for(int i = 0; i < numbers.length; i++) {
if(numbers[i] < minNum ) {
minNum = numbers[i];
}
}
System.out.println("Min: "+minNum);
}
}
In: Computer Science
Create a C++ program which will prompt the user to enter a password continually until the password passes the following tests.
Password is 6 chars long
Password has at least 1 number
If the input does not match the tests, it will input a specific error message. "Pass must be 6 chars long."
If the input is allowed, print a message saying "Correct Password Criteria."
In: Computer Science
Algorithm design:Suppose that three types of parentheses are allowed in an expression: parentheses, square brackets, and curly braces. Please design an efficient algorithm to determine whether the parentheses in the expression are correctly paired. Please write down the algorithm idea and steps.
Please explain what kind of data structure is used to solve the problem, and then give the specific algorithm steps
In: Computer Science