import java.awt.*;
import javax.swing.JButton;
import javax.swing.JFrame;
public class GridBagLayoutDemo {
final static boolean shouldFill = true;
final static boolean shouldWeightX = true;
final static boolean RIGHT_TO_LEFT = false;
public static void addComponentsToPane(Container pane) {
if (RIGHT_TO_LEFT) {
pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
}
JButton button;
pane.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
if (shouldFill) {
//natural height, maximum width
c.fill = GridBagConstraints.HORIZONTAL;
}
button = new JButton("Button 1");
if (shouldWeightX) {
c.weightx = 0.5;
}
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
pane.add(button, c);
button = new JButton("Button 2");
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0.5;
c.gridx = 1;
c.gridy = 0;
pane.add(button, c);
button = new JButton("Button 3");
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0.5;
c.gridx = 2;
c.gridy = 0;
pane.add(button, c);
button = new JButton("Long-Named Button 4");
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady = 40; //make this component tall
c.weightx = 0.0;
c.gridwidth = 3;
c.gridx = 0;
c.gridy = 1;
pane.add(button, c);
button = new JButton("5");
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady = 0; //reset to default
c.weighty = 1.0; //request any extra vertical space
c.anchor = GridBagConstraints.PAGE_END; //bottom of space
c.insets = new Insets(10,0,0,0); //top padding
c.gridx = 1; //aligned with button 2
c.gridwidth = 2; //2 columns wide
c.gridy = 2; //third row
pane.add(button, c);
}
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("GridBagLayoutDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Set up the content pane.
addComponentsToPane(frame.getContentPane());
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
I need someone to go through this program and right more comments that explain a lot more Please. from top to bottom Thanks
In: Computer Science
i want it in C++.You will solve the Towers of Hanoi problem in
an iterative manner (using Stack) in C++(using data
structure).
Note: you have to solve for N number of disks, 3 Towers (Stacks).
Do not use recursion.
For better understanding play the game at least once.
Link:https://www.mathsisfun.com/games/towerofhanoi.html
In: Computer Science
You are now the manager of a small team of software engineers. Some of them are fresh graduates, while some of them have a few years of working experience in the field. You are tasked with producing a small experimental FinTech (Financial Technology) mobile application. You will need to publish on both Android and iPhone platforms. You are adopting an Agile methodology, with emphasis on Test-Driven Development and extensive automated tests. The concept behind the application is very innovative, so design is constantly changing.
Your team consultant, William, believes the team should spend less time on planning and more time on producing first prototypes, and then revise our design based on further feedback. Do you agree with his approach? If yes, which practice in Agile methodology is in agreement with this approach?
In: Computer Science
write a program using Java language that is-
Implement Stack with a linked list, and demonstrate that it can solve the Tower of Hanoi problem.
Write implementation body of method “infixToPrefix(String[] e)” of class ArithmeticExpression to convert infix expressions into prefix expressions.
In: Computer Science
Consider the language L over alphabets (a, b) that produces
strings of the form aa* (a + b) b*a.
a) Construct a nondeterministic finite automata (NFA) for the
language L given above.
b) Construct a deterministic finite automaton (DFA) for the NFA you have constructed above.
In: Computer Science
In: Computer Science
Python Programming
I have a skeleton code here for this project but do not know exactly where to start. My task is to implement a reliable File Transfer Protocol (FTP) service over UDP. I need help to write the reliable FTP client and server programs based on an Alternating Bit Protocol (ABP) that will communicate with a specially designated server. In socket-level programming as well...
# program description
# Library imports
from socket import *
import sys
import time
# Variable declarations
server = "harp.ece.vt.edu" # server
tcpPort = 21000 # TCP listening port
buffer = 4096 # defines the size of acceptable data for receipt
message ="debug" # controls condition of transfered data. debug: no delay or corruption
# normal: server introduces delays and errors into transmission
# Initialize variables
# sequence number value 1
# sequence number value 0
# Temporary variable for alternating sequence numbers
# control value transfer in progress
# initial setting is for ACK1 but changes during execution
# calculated by a char by char ordinal sum of the packet
# value is then converted to 4-digit ASCII value via
# sum mod 10000
PAYLOAD = ""
udpPort = 0 # variable to hold udpPort number
completeFile = [] # accumulation of complete file transfer
serverResponse = "" # server response variable
endFile = False # flag for end of transmission
badPacket = False #flag for bad checksum comparison
# Create socket variable
sTCP = socket(AF_INET, SOCK_STREAM) # TCP socket definition
sUDP = socket(AF_INET, SOCK_DGRAM) # UDP socket definition
# send ACK packet to server
Some further instructions include:
The four fields of the “RFP” protocol are:
● SEQUENCE: This is the sequence number of the packet, and can legally assume either of the two values: “0000” or “0001”.
● CHECKSUM: This is a 4-digit ASCII number that is the byte-by-byte sum, modulo-10000, of all data in the payload including the header SEQUENCE and header CONTROL.
● CONTROL: Used by the server to indicate Transfer in Progress “0000” or All Done “0001”. The client should set this field to “0000”. “0002” is reserved for future use.
● DATA: Used by the server to send part of the data file it is transferring
We will establish a “channel” here, the server will respond with a unique UDP port for you to use for your file transfer: 1. Open a TCP connection to harp.ece.vt.edu over port 21000 2. Send the word “normal” to the server over this port. 3. The server will respond with a number formed in an ASCII string. This is the UDP port that you shall use in the file transfer session. 4. Close the TCP connection. Once you have been assigned a UDP port, you are ready to start the file transfer after you open the socket.
To initiate the file transfer, the client should send an ACK1 packet (sequence number = “0001”, control = “0000”, a computed checksum, and zero bytes of data). As stated above, the checksum is the character-by-character ordinal sum over the entire packet (excluding the checksum field). For the ACK1 packet, checksum = “0”+”0”+“0”+”1”+“0”+”0”+“0”+”0” = ASCII 48 + 48 + 48 + 49 +48 + 48 + 48 + 48 = 385. The 4-digit modulo-10000 ASCII decimal equivalent of this checksum is “0385.” 1 The server will then start sequentially sending the file data, starting with a packet with Sequence Number 0. Abide by the Alternating Bit Protocol to transfer the contents of the file. When the server has completed the file transfer, it will send a final packet with no data with the control field set to “0001.” You must ACK this packet. Then you can close your UDP session and save the output file.
Since the file will be larger than a single packet, the server will segment the file into chunks that will fit within packets. The client will need to reassemble these and put them in a file called reliable.txt.
In: Computer Science
Consider that time could be internally represented as 3 integers.
MyTime class consists of the following members:
Complete the MyTime class definition and write a main program to test your class in Java.
In: Computer Science
Explain how you would secure your company’s internal wireless network to prevent unauthorized access, including how it’s configured and what policies might need to be created and enforced to ensure employee compliance.
In: Computer Science
Enterprise architecture is often dependent on the vision, mission, goals, and strategies of an organization. Independence Medical Center's current mission and vision statements follow:
Use the Internet to find descriptions of two organizations' enterprise structures or data governance programs. Compare the two, noting the pros and cons of each.
Post rough drafts of updates to the vision and mission statements for Independence Medical Center, incorporating the concept of enterprise information management based on your research.
Cite at least one reference using APA format in your initial post.
In: Computer Science
You are about to implement the wireless network security measures and policies you just described above, and your boss sends you to talk with two operations managers. The managers are concerned that new restrictions will inhibit their workers and lower performance, which would create a risk to the company in meeting its minimum production levels. Your task (to answer this question) is to explain to the managers how the wireless security measures and policies relate to risk management for the company and alleviate the managers’ concerns.
In: Computer Science
The industrialization of the world has been described as a “Faustian bargain.” Another perspective holds that industrialization has freed humanity from the bonds imposed by nature. Based on the readings in this module, as well as on your own experience and other readings, do you agree with one of these positions? If so, why? If not, do you have an alternative perspective?
In: Computer Science
Briefly describe at least six (6) ways to harden a network, including servers and workstations, and the network configuration (architecture); then explain in detail the first two steps you would take toward achieving a secure network.
In: Computer Science
Based on a Node class;
Use Java to implement the OrderedList class which represents an ordered singly linked list that cannot contain any duplicates. Note that items in the OrderedList are always kept in descending order. Complete the class with the following methods.
Then write the program that accepts a sequence of commands and print out the number of successful insertions, the number of successful deletions, the number of successful searches (through the “find” command), the number of items remaining in the list after executing all commands and the final contents of the list.
There are 3 commands which are “insert”, “delete” and “find”.
Input
Line 1: The number of transactions m on the list, where 1 m 200.
Line 2 to m+1: A string command (“insert”, “delete”, “find”) followed by an integer n (separated by a space).
Output
Line 1: Display 4 integers (each number is separated by a space) which are:
Line 2: The final contents of the list
|
Sample Input |
Sample Output |
|
3 insert 1 delete 5 find 2 |
1 0 0 1 [ 1 ] |
|
8 find 10 insert 3 insert 2 insert 1 delete 4 delete 3 insert 1 find 2 |
3 1 1 2 [ 2 1 ] |
In: Computer Science
Please explain the differences between DHCP and DNS and discuss their purposes. I'm not looking for an easy google search, I need examples and explanations to help understand the concepts
In: Computer Science