1. Servlet program to find the information about an account
holder at a bank.
( Bank name= your name )
(I'm using netbeans with glassfish, lecturer mentioned not to use
jsp, mostly use CSS, Javascript, html, xml)
• Case:
a) Have username and password authentication
b) Display his Account balance to be RM10000,
c) Show different functionalities of a bank account (Deposit,
Withdrawal, Print)
d) For every transaction make sure make use of his account
balance.
e) Perform the functionalities(Deposit, Withdraw and print) until
the user selects
to stop.
In: Computer Science
– Consider an XYZ Hypermarket in the Sultanate of Oman. The hypermarket has got a lot of branches spread across different Wilayats in the country. As a database administrator, which client server architecture will you be preferring for this hypermarket and why. Support you answer with valid in-text citations and references.
In: Computer Science
In order to implement a DNS amplification attack, the attacker must trigger the creation of a sufficiently large volume of DNS response packets from the intermediary to exceed the capacity of the link to the target organization. Consider an attack where the DNS response packets are 1000 bytes in size (ignoring framing overhead).
How many of these packets per second must the attacker trigger to flood a target organization using a 30-Mbps link? A 100-Mbps link? Or a 1-Gbps link?
If the DNS request packet to the intermediary is 60 bytes in size, how much bandwidth does the attacker consume to send the necessary rate of DNS request packets for each of these three cases?
In: Computer Science
Q17. Fill in the blanks:
Consider the operands to be signed words (16 bit)
a) mov ax, - 48 cwd mov bx , 5 idiv bx ; ax = _______ , dx = _____ (provide answers in decimal) Consider the operands to be signed words (16 bit)
b) mov ax , -1 mov bx , -1 imul bx ; ax = _________H, dx =__________H (provide answer in Hex) Consider the operands to be signed words
c) mov ax , -1 mov dx , 2 imul dx ; ax = _______H ,dx = ________H(provide answer in Hex) Consider the operands to be signed byte (8 bit)
d) mov al, -48 cbw mov bl, 5 idiv bl ; al = _____, ah = _______ (provide answers in decimal) 5
Q18. Fill in the values as the following code fragment is executed:
a) count DB 9A H ; count is Byte variable initialized to 9A H num DB BC H ; num is a Byte variable initialized to BCH mov ah, count mov al, num ; ax = _______________H
b) mov ax, 1234H mov ax, ‘A’ ; ax = ________________H (Hint: ASCII code of ‘A’ = 65 in decimal)
c ) mov dx , 0087H mov ax, 6000H mov bx, 100H div bx ; ax = ________________H
d) mov ax, 1237H sub al, 38H ; ax = ________________H
In: Computer Science
Provide an example of a real-time application and, to the best of your knowledge, discuss its following aspects:
What would be the involved periodic tasks? What would be their release time (or release-time jitter)?
What would be the aperiodic tasks in the application? What would be their release time, i.e., events that would trigger the aperiodic tasks?
What would be the sporadic tasks in the application?
What would be their release time, i.e., events that would trigger the aperiodic tasks?
In: Computer Science
There's an array named score, 90, 98, 92, 88, 100, 80 are the elements in this array.
Please write a Java program to declare and sort this array (use selection sort).
In: Computer Science
I need the java code for a 4 function calculator app on android studio (do this on android studio) -
The requirements are the following :
- The only buttons needed are 0-9, *, /, +, -, a clear, and enter button
- Implement the onclicklistener on the main activity
- The calcuator should use order of operations (PEMDAS)
- It should be able to continue from a previous answer (Ex: If you type 2+6 the calculator will display 8. If you then multiple by 2 the current result will simply be multiplied by 2)
- It should read the entire sequence of numbers and operators and save them into a String. The information can be read out of the String using a StringTokenizer. The delimiters will be the operators on the calculator.
- The entire mathematical expression will be displayed on the screen before the equal button is clicked.
- The equation will simply be evaluated in the order that the user types in the numbers rather than the precedence
- If the user enters an equation with invalid syntax, the output should display “error”. The calculator should also display “error” for any mathematical calculations that are impossible.
In: Computer Science
1 import java.util.Random;
2
3 /* This class ecapsulates the state and logic required to play
the
4 Stick, Water, Fire game. The game is played between a user and
the computer.
5 A user enters their choice, either S for stick, F for fire, W for
water, and
6 the computer generates one of these choices at random- all
equally likely.
7 The two choices are evaluated according to the rules of the game
and the winner
8 is declared.
9
10 Rules of the game:
11 S beats W
12 W beats F
13 F beats S
14 no winner on a tie.
15
16 Each round is executed by the playRound method. In addition to
generating the computer
17 choice and evaluating the two choices, this class also keeps
track of the user and computer
18 scores, the number of wins, and the total number of rounds that
have been played. In the case
19 of a tie, neither score is updated, but the number of rounds is
incremented.
20
21 NOTE: Do not modify any of the code that is provided in the
starter project. Additional instance variables and methods
22 are not required to make the program work correctly, but you may
add them if you wish as long as
23 you fulfill the project requirements.
24
25 */
26 public class StickWaterFireGame {
27
28
29 // TODO 1: Declare private instance variables here:
30
31
32 /* This constructor assigns the member Random variable, rand,
to
33 * a new, unseeded Random object.
34 * It also initializes the instance variables to their default
values:
35 * rounds, player and computer scores will be 0, the playerWins
and isTie
36 * variables should be set to false.
37 */
38 public StickWaterFireGame() {
39 // TODO 2: Implement this method.
40
41 }
42
43 /* This constructor assigns the member Random variable, rand,
to
44 * a new Random object using the seed passed in.
45 * It also initializes the instance variables to their default
values:
46 * rounds, player and computer scores will be 0, the playerWins
and isTie
47 * variables should be set to false.
48 */
49 public StickWaterFireGame(int seed) {
50 // TODO 3: Implement this method.
51
52 }
53
54 /* This method returns true if the inputStr passed in is
55 * either "S", "W", or "F", false otherwise.
56 * Note that the input can be upper or lower case.
57 */
58 public boolean isValidInput(String inputStr) {
59 // TODO 4: Implement this method.
60 return false;
61 }
62
63 /* This method carries out a single round of play of the SWF
game.
64 * It calls the isValidInput method and the getRandomChoice
method.
65 * It implements the rules of the game and updates the instance
variables
66 * according to those rules.
67 */
68 public void playRound(String playerChoice) {
69 // TODO 12: Implement this method.
70 }
71
72 // Returns the choice of the computer for the most recent round
of play
73 public String getComputerChoice(){
74 // TODO 5: Implement this method.
75 return null;
76 }
77
78 // Returns true if the player has won the last round, false
otherwise.
79 public boolean playerWins(){
80 // TODO 6: Implement this method.
81 return false;
82 }
83
84 // Returns the player's cumulative score.
85 public int getPlayerScore(){
86 // TODO 7: Implement this method.
87 return 0;
88 }
89
90 // Returns the computer's cumulative score.
91 public int getComputerScore(){
92 // TODO 8: Implement this method.
93 return 0;
94 }
95
96 // Returns the total nuber of rounds played.
97 public int getNumRounds(){
98 // TODO 9: Implement this method.
99 return 0;
100 }
101
102 // Returns true if the player and computer have the same score
on the last round, false otherwise.
103 public boolean isTie(){
104 // TODO 10: Implement this method.
105 return false;
106 }
107
108 /* This "helper" method uses the instance variable of Random to
generate an integer
109 * which it then maps to a String: "S", "W", "F", which is
returned.
110 * This method is called by the playRound method.
111 */
112 private String getRandomChoice() {
113 // TODO 11: Implement this method.
114 return null;
115 }
116 }
117
In: Computer Science
Record a macro that sets Cell B5 to a format of Bold and sets the Number format to be in $. Copy the VBA code for that macro and paste it.
In: Computer Science
Use C++ language
3. Ask the user to pick a number between 1 and 100. You (the program) should try and guess the number the user picked. The user can tell you if their number is higher or lower, but that is all. The program should run until the computer guesses correctly.
In: Computer Science
what is the concept of bottleneck link?
In: Computer Science
Java iteration method, I need a method which iterates through a collection of books and adjusts the price of all books published between the given parameters to give a 20% discount off the price of each book published between the given years?
Book class
public class Book
{
private String title;
private String author;
private int yearPublished;
private double bookPriceInCAD;
public Book(String inputTitle, String
inputAuthor, int inputYearPublished, double
inputBookPriceInCAD){
setTitle(inputTitle);
setAuthor(inputAuthor);
setYearPublished(inputYearPublished);
setBookPriceInCAD(inputBookPriceInCAD);
}
public String getTitle(){
return title;
}
public String getAuthor(){
return author;
}
public int getYearPublished(){
return
yearPublished;
}
public double getBookPriceInCAD(){
return
bookPriceInCAD;
}
public void setTitle(String title){
if(title !=null
&& !title.isEmpty()){
this.title = title;
} else if(title ==
null){
throw new IllegalArgumentException("title cannot be null");
} else
if(title.isEmpty()){
throw new IllegalArgumentException("title cannot be an empty
String");
}
}
public void setAuthor(String
author){
if(author !=null
&& !author.isEmpty()){
this.author = author;
} else if(author ==
null){
throw new IllegalArgumentException("author cannot be null");
} else
if(author.isEmpty()){
throw new IllegalArgumentException("author cannot be an empty
String");
}
}
public void setYearPublished(int
yearPublished){
if(yearPublished >
0){
this.yearPublished = yearPublished;
} else {
throw new IllegalArgumentException("year published cannot be
negative");
}
}
public void setBookPriceInCAD(double
bookPriceInCAD){
if(bookPriceInCAD >
0){
this.bookPriceInCAD = bookPriceInCAD;
} else {
throw new IllegalArgumentException("book price in CAD cannot be
negative");
}
}
BookStore Class
import java.util.ArrayList;
import java.util.Iterator;
public class BookStore
{
private ArrayList<Book> bookList;
private String businessName;
public BookStore()
{
// initialise instance
variables
bookList = new
ArrayList<Book>();
businessName = "Book
Store";
}
public BookStore(String
inputBusinessName){
setBusinessName(inputBusinessName);
bookList = new
ArrayList<Book>();
}
public void setBusinessName(String
businessName){
if(businessName !=null
&& !businessName.isEmpty()){
this.businessName = businessName;
} else if(businessName
== null){
throw new IllegalArgumentException("business Name cannot be
null");
} else
if(businessName.isEmpty()){
throw new IllegalArgumentException("business Name cannot be an
empty String");
}
}
public String getBusinessName(){
return
businessName;
}
public ArrayList<Book>
getBookList(){
return bookList;
}
public void addBook(Book book){
if(book!=null){
bookList.add(book);
}
}
public void getBook(int index) {
if((index >= 0) && (index <=
bookList.size())) {
Book oneBook =
bookList.get(index);
oneBook.displayDetails();
}
else{
System.out.println("Invalid index position");
}
}
public void searchBook(String title){
for(Book b:
bookList){
String bookTitle =
b.getTitle();
if(bookTitle.equalsIgnoreCase(title)){
b.displayDetails();
} else{
System.out.println("book not found");
}
}
}
public void displayBookDetails(){
for(Book oneBook:
bookList){
oneBook.displayDetails();
}
}
public static void main(String[] args){
BookStore list = new
BookStore();
Book b1 = new
Book("hello world","steven segal",2005,20.00);
Book b2 = new
Book("goodbye world","Jeff country", 208,10.00);
Book b3 = new Book("no
world","Bill Nye",202,30.00);
list.addBook(b1);
list.addBook(b2);
list.addBook(b3);
list.getBook(4);
list.getBook(2);
list.displayBookDetails();
}
public int donateBook(int
yearPublished){
Iterator<Book>
iter = bookList.iterator();
int count = 0;
while(iter.hasNext()){
Book aBook = iter.next();
if(yearPublished <= aBook.getYearPublished()){
iter.remove();
count++;
}
}
return count;
}
public void applyDiscountToBook(int
beginYear, int endYear){
}
In: Computer Science
Implement a priority queue using a DoublyLinkedList where the
node with the highest priority (key) is the right-most node.
The remove (de-queue) operation returns the node with the highest
priority (key).
If displayForward() displays List (first-->last) : 10 30 40
55
remove() would return the node with key 55.
Demonstrate by inserting keys at random, displayForward(), call
remove then displayForward() again.
You will then attach a modified DoublyLinkedList.java (to contain
the new priorityInsert(long key) and
priorityRemove() methods), and a driver to
demonstrate as shown above.
Use the provided PQDoublyLinkedTest.java to test your code.
public class PQDoublyLinkedTest
{
public static void main(String[] args)
{ // make a new list
DoublyLinkedList theList = new DoublyLinkedList();
theList.priorityInsert(22); // insert at front
theList.priorityInsert(44);
theList.priorityInsert(66);
theList.priorityInsert(11); // insert at rear
theList.priorityInsert(33);
theList.priorityInsert(55);
theList.priorityInsert(10);
theList.priorityInsert(70);
theList.priorityInsert(30);
theList.displayForward(); // display list forward
Link2 removed = theList.priorityRemove();
System.out.print("priorityRemove() returned node with key: ");
removed.displayLink2();
} // end main()
} // end class PQDoublyLinkedTest
_____________________________________________________________________________________________________________________________________________________
// doublyLinked.java
// demonstrates doubly-linked list
// to run this program: C>java DoublyLinkedApp
class Link
{
public long dData; // data item
public Link next; // next link in list
public Link previous; // previous link in list
public Link(long d) // constructor
{ dData = d; }
public void displayLink() // display this link
{ System.out.print(dData + " "); }
} // end class Link
class DoublyLinkedList
{
private Link first; // ref to first item
private Link last; // ref to last item
public DoublyLinkedList() // constructor
{
first = null; // no items on list yet
last = null;
}
public boolean isEmpty() // true if no links
{ return first==null; }
public void insertFirst(long dd) // insert at front of list
{
Link newLink = new Link(dd); // make new link
if( isEmpty() ) // if empty list,
last = newLink; // newLink <-- last
else
first.previous = newLink; // newLink <-- old first
newLink.next = first; // newLink --> old first
first = newLink; // first --> newLink
}
public void insertLast(long dd) // insert at end of list
{
Link newLink = new Link(dd); // make new link
if( isEmpty() ) // if empty list,
first = newLink; // first --> newLink
else
{
last.next = newLink; // old last --> newLink
newLink.previous = last; // old last <-- newLink
}
last = newLink; // newLink <-- last
}
public Link deleteFirst() // delete first link
{ // (assumes non-empty list)
Link temp = first;
if(first.next == null) // if only one item
last = null; // null <-- last
else
first.next.previous = null; // null <-- old next
first = first.next; // first --> old next
return temp;
}
public Link deleteLast() // delete last link
{ // (assumes non-empty list)
Link temp = last;
if(first.next == null) // if only one item
first = null; // first --> null
else
last.previous.next = null; // old previous --> null
last = last.previous; // old previous <-- last
return temp;
}
// insert dd just after key
public boolean insertAfter(long key, long dd)
{ // (assumes non-empty list)
Link current = first; // start at beginning
while(current.dData != key) // until match is found,
{
current = current.next; // move to next link
if(current == null)
return false; // didn't find it
}
Link newLink = new Link(dd); // make new link
if(current==last) // if last link,
{
newLink.next = null; // newLink --> null
last = newLink; // newLink <-- last
}
else // not last link,
{
newLink.next = current.next; // newLink --> old next
// newLink <-- old next
current.next.previous = newLink;
}
newLink.previous = current; // old current <-- newLink
current.next = newLink; // old current --> newLink
return true; // found it, did insertion
}
public Link deleteKey(long key) // delete item w/ given key
{ // (assumes non-empty list)
Link current = first; // start at beginning
while(current.dData != key) // until match is found,
{
current = current.next; // move to next link
if(current == null)
return null; // didn't find it
}
if(current==first) // found it; first item?
first = current.next; // first --> old next
else // not first
// old previous --> old next
current.previous.next = current.next;
if(current==last) // last item?
last = current.previous; // old previous <-- last
else // not last
// old previous <-- old next
current.next.previous = current.previous;
return current; // return value
}
public void displayForward()
{
System.out.print("List (first-->last): ");
Link current = first; // start at beginning
while(current != null) // until end of list,
{
current.displayLink(); // display data
current = current.next; // move to next link
}
System.out.println("");
}
public void displayBackward()
{
System.out.print("List (last-->first): ");
Link current = last; // start at end
while(current != null) // until start of list,
{
current.displayLink(); // display data
current = current.previous; // move to previous link
}
System.out.println("");
}
} // end class DoublyLinkedList
class DoublyLinkedApp
{
public static void main(String[] args)
{ // make a new list
DoublyLinkedList theList = new DoublyLinkedList();
theList.insertFirst(22); // insert at front
theList.insertFirst(44);
theList.insertFirst(66);
theList.insertLast(11); // insert at rear
theList.insertLast(33);
theList.insertLast(55);
theList.displayForward(); // display list forward
theList.displayBackward(); // display list backward
theList.deleteFirst(); // delete first item
theList.deleteLast(); // delete last item
theList.deleteKey(11); // delete item with key 11
theList.displayForward(); // display list forward
theList.insertAfter(22, 77); // insert 77 after 22
theList.insertAfter(33, 88); // insert 88 after 33
theList.displayForward(); // display list forward
} // end main()
} // end class DoublyLinkedApp
____________________________________________________________________________________________________________________________________________________
In: Computer Science
A. There are 10 users whose traffic is being multiplexed over a single link with a capacity of 2 Mbps. Suppose each user generates 100 kbps when busy, but is only busy (i.e., has data to send) 10% of the time. Would circuit-switching or packet-switching be preferable in this scenario? Why?
B. Continuing the previous problem, assume that the link capacity is still 2 Mbps, but the amount of traffic each user has to send when busy is increased to 1 Mbps, and that each of the 10 users still only has data to send 10% of the time. Would circuit-switching or packet-switching be preferable in this scenario? Why?
In: Computer Science
A client sends a TCP segment to the server with Sequence Number 1400 and the payload included in the segment is 1399 bytes long.
- A. What is the ACK Number in the acknowledgement that is returned from the server?
- B. Assume this packet is lost but the following packet is received. What is the ACK Number in the acknowledgement that is returned from the server for this packet?
- C. Provide a detailed explanation for part B.
In: Computer Science