Questions
Many Projects are running in the company. The CEO of company wants to know about the...

Many Projects are running in the company. The CEO of company wants to know about the details of his current projects. Write a SQL query that retrieves each project record.

In: Computer Science

this there any way to shorten the line of  code. Right now it about 300 line of...

this there any way to shorten the line of  code. Right now it about 300 line of code is there anyway to shorten it to 200 or so line of code?

import java.awt.*;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.event.*;
import java.net.URL;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
//MyMenuFrame will use Jframe with actionlistener
class MyMenuFrame extends JFrame implements ActionListener{

//creating the main menu items
JMenu menuEdit = new JMenu("Edit");
JMenu menuPrint = new JMenu("Print");
JMenu mnFile = new JMenu("File");
JMenu menuHelp = new JMenu("Help");


//creating the submenu items here because we are gonna use these across the code
JRadioButton subMenuItem1 = new JRadioButton("Times New Roman");
JRadioButton subMenuItem2 = new JRadioButton("Arial");
JRadioButton subMenuItem3 = new JRadioButton("Serif");
JCheckBox subMenuItem4 = new JCheckBox("Bold");
JCheckBox subMenuItem5 = new JCheckBox("Italic");

//provide scrollable view of a component
JScrollPane scrollPane;

//creating notePadArea for notepad to input the text
JTextArea notePadArea;

public MyMenuFrame() {

//setting the border layout for JFrame
this.setLayout(new BorderLayout());

// create menu bar named menuBar

JMenuBar menuBar = new JMenuBar();

this.setJMenuBar(menuBar);//adding the menubar to JFrame

// create File menu
mnFile.setMnemonic(KeyEvent.VK_F);//Alt+F

menuBar.add(mnFile);//adding the menufile

// create Open menu item

JMenuItem mntmOpen = new JMenuItem("Open");//creating the Open menu

mntmOpen.setMnemonic(KeyEvent.VK_O);//Alt+O command

mntmOpen.setActionCommand("open");//when the command equals to 'open' then the corresponding action will be performed

mntmOpen.setAccelerator(KeyStroke.getKeyStroke('O', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+O

mntmOpen.addActionListener(this);//adding actionLister to the Menu Option Open


// create Save menu item

JMenuItem mntmSave = new JMenuItem("Save");//creating the Save menu

mntmSave.setMnemonic(KeyEvent.VK_S);//Alt+S command

mntmSave.setActionCommand("save");//when the command equals to 'save' then the corresponding action will be performed

mntmSave.setAccelerator(KeyStroke.getKeyStroke('S', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+S

mntmSave.addActionListener(this);//adding actionLister to the Menu Option Save

// create Exit menu item

JMenuItem mntmExit = new JMenuItem("Exit");//creating the Exit menu

mntmExit.setMnemonic(KeyEvent.VK_X);//Alt+X command

mntmExit.setActionCommand("exit");//when the command equals to 'exit' then the corresponding action will be performed

mntmExit.setAccelerator(KeyStroke.getKeyStroke('X', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+X

mntmExit.addActionListener(this);//adding actionLister to the Menu Option Exit

// add open, save and exit menu to menu-bar

mnFile.add(mntmOpen);

mnFile.addSeparator();//adding separator between open and save

mnFile.add(mntmSave);

mnFile.addSeparator();//adding separator between save and exit

mnFile.add(mntmExit);

// create Edit menu

menuEdit.setMnemonic(KeyEvent.VK_E);//creating shortcut menu when user press Alt+E

menuBar.add(menuEdit);//adding the Edit to the menubar

JMenu submenu1 = new JMenu("Color");//creating the new menu which comes under Edit
submenu1.setMnemonic(KeyEvent.VK_C);//creating shortcut menu when user press Alt+C
JMenuItem menuItem0 = new JMenuItem("Change Color");//creating submenu item called change color
menuItem0.setAccelerator(KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK));//it responds when user click Ctrl+C
menuItem0.setActionCommand("color");//setting the command used to call the correcponding action when user click this
menuItem0.addActionListener(this);//adding actionlistener
submenu1.add(menuItem0);//adding this menu item to submenu
menuEdit.add(submenu1);//adding this submenu to editmenu
menuEdit.addSeparator();//creating separator between Color and Font

ActionListener sm1 = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
subMenuItem1.setSelected(true);
subMenuItem2.setSelected(false);
subMenuItem3.setSelected(false);
notePadArea.setFont(new Font("Times New Roman", Font.PLAIN, 20));
}
};

ActionListener sm2 = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
subMenuItem2.setSelected(true);
subMenuItem1.setSelected(false);
subMenuItem3.setSelected(false);
notePadArea.setFont(new Font("Arial", Font.PLAIN, 20));

}
};

ActionListener sm3 = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
subMenuItem3.setSelected(true);
subMenuItem2.setSelected(false);
subMenuItem1.setSelected(false);
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));

}
};

JMenu submenu = new JMenu("Font");//creating the new menu which comes under Edit
submenu.setMnemonic(KeyEvent.VK_F);//creating shortcut menu when user press Alt+F
subMenuItem1.setMnemonic(KeyEvent.VK_T);//creating shortcut menu when user press Alt+T for Times New Roman
subMenuItem1.setActionCommand("times_new_roman");//setting the command used to call the correcponding action when user click this
subMenuItem1.addActionListener(sm1);//adding actionlistener
submenu.add(subMenuItem1);//adding to the submenu


subMenuItem2.setMnemonic(KeyEvent.VK_A);//creating shortcut key Alt+A
subMenuItem2.setActionCommand("arial");//respond when the command equals to arial
subMenuItem2.addActionListener(sm2);//adding action listener
submenu.add(subMenuItem2);//adding it to the submenu

subMenuItem3.setMnemonic(KeyEvent.VK_S);
subMenuItem3.setActionCommand("serif");
subMenuItem3.addActionListener(sm3);
submenu.add(subMenuItem3);

submenu.addSeparator();

subMenuItem4.setMnemonic(KeyEvent.VK_B);
subMenuItem4.setActionCommand("bold");
subMenuItem4.addActionListener(this);
submenu.add(subMenuItem4);

subMenuItem5.setMnemonic(KeyEvent.VK_I);
subMenuItem5.setActionCommand("italic");
subMenuItem5.addActionListener(this);
submenu.add(subMenuItem5);

menuEdit.add(submenu);


// create Print menu


menuPrint.setMnemonic(KeyEvent.VK_P);

menuBar.add(menuPrint);

JMenuItem menuItemPrint = new JMenuItem("Send To Printer");

menuItemPrint.setAccelerator(KeyStroke.getKeyStroke('P', KeyEvent.CTRL_DOWN_MASK));

menuItemPrint.setActionCommand("print");

menuItemPrint.addActionListener(this);

menuPrint.add(menuItemPrint);

// create Help menu

menuHelp.setMnemonic(KeyEvent.VK_H);


menuBar.add(menuHelp);

JMenuItem menuItemHelp = new JMenuItem("About");

menuItemHelp.setAccelerator(KeyStroke.getKeyStroke('A', KeyEvent.CTRL_DOWN_MASK));

menuItemHelp.setActionCommand("about");
menuItemHelp.addActionListener(this);

JMenuItem menuItemVisitHomePage = new JMenuItem("Visit Home Page");

menuItemVisitHomePage.setAccelerator(KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK));

menuItemVisitHomePage.setActionCommand("visithomepage");
menuItemVisitHomePage.addActionListener(this);

menuHelp.add(menuItemHelp);

menuHelp.addSeparator();

menuHelp.add(menuItemVisitHomePage);

notePadArea = new JTextArea();

// set no word wrap

notePadArea.setWrapStyleWord(false);

// create scrollable pane

scrollPane = new JScrollPane(notePadArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS , JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

this.add(scrollPane,BorderLayout.CENTER);

}


@Override

public void actionPerformed(ActionEvent e) {

if(e.getActionCommand().equals("exit")) {

System.exit(0);

}else if (e.getActionCommand().equals("open")) {

JFileChooser file = new JFileChooser();

String fileName = "";//initial filename was empty

// show open file dialog

if (file.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {

fileName = file.getSelectedFile().getAbsolutePath();

} else {

return;

}

try(BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));) {

// load file content into text area

StringBuffer stringBuffer = new StringBuffer();//creating a string buffer for reading data from file

String lines = "";//for reading the lines from the selecting file

while((lines = bufferedReader.readLine() ) != null) {//it'll read untill the file ends

stringBuffer.append(lines).append("\n");//for every line read insert new line in stringBuffer

}

bufferedReader.close();//after reading of file done, the bufferedReader will be close

notePadArea.setText(stringBuffer.toString());//converting the read text to string and inserting this text into textArea

} catch (Exception error1) {//if any exception occures

System.out.println(error1.toString());//convert the expection into string and print it

}

} else if (e.getActionCommand().equals("save")) {//if the user click the save command then the file will gonna saved


JFileChooser file = new JFileChooser();//creating the file chooser

String fileName = "";//initial file name is empty

// show open file dialog

if (file.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {//if the user select file and clicks OK button

fileName = file.getSelectedFile().getAbsolutePath();

} else {//other wise will be closed
return;
}

try(BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(fileName));) {

// write editor's content to selected file.

bufferedWriter.write(notePadArea.getText());//get the text entered in textarea
bufferedWriter.flush();//clear the writer
} catch(Exception ex1) {}

} else if (e.getActionCommand().equals("color")) {

Color select_color = JColorChooser.showDialog(this, "Select a color", Color.RED);
notePadArea.setForeground(select_color);

} else if (e.getActionCommand().equals("times_new_roman")) {
if(subMenuItem1.isSelected())
notePadArea.setFont(new Font("Times New Roman", Font.PLAIN, 20));

} else if (e.getActionCommand().equals("arial")) {
if(subMenuItem2.isSelected())
notePadArea.setFont(new Font("Arial", Font.PLAIN, 20));

} else if (e.getActionCommand().equals("serif")) {
if(subMenuItem3.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));

} else if (e.getActionCommand().equals("bold")) {
if(subMenuItem4.isSelected()){
if(subMenuItem5.isSelected()){
notePadArea.setFont(new Font("Serif", Font.BOLD+Font.ITALIC, 20));
}else{
notePadArea.setFont(new Font("Serif", Font.BOLD, 20));
}
}else{
if(!subMenuItem5.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));
}

} else if (e.getActionCommand().equals("italic")) {

if(subMenuItem5.isSelected()){
if(subMenuItem4.isSelected()){
notePadArea.setFont(new Font("Serif", Font.BOLD+Font.ITALIC, 20));
}else{
notePadArea.setFont(new Font("Serif", Font.ITALIC, 20));
}
}else{
if(!subMenuItem4.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));
}

} else if (e.getActionCommand().equals("print")) {

int output = JOptionPane.showConfirmDialog(this, "Do you want to print the File","Confirmation", JOptionPane.YES_NO_OPTION);
if(output==0){
JOptionPane.showMessageDialog(this, "The file is successfully printed","Confirmation", JOptionPane.INFORMATION_MESSAGE);
}
} else if (e.getActionCommand().equals("changecolor")){
System.out.println("Color clicked");
}
else if (e.getActionCommand().equals("about")) {

JOptionPane.showMessageDialog(this, "This software is developed in 2019\nVersion is 1.0","About", JOptionPane.INFORMATION_MESSAGE);

} else if (e.getActionCommand().equals("visithomepage")) {

openWebpage("http://www.microsoft.com");

}

}

private void openWebpage (String urlString) {

try {

Desktop.getDesktop().browse(new URL(urlString).toURI());

}

catch (Exception e) {

e.printStackTrace();
}
}
}

import javax.swing.JFrame;
public class MyMenuFrameTest {
public static void main(String[] args) {
MyMenuFrame frame = new MyMenuFrame();
frame.setTitle("MyNotepad");
//for the title of the box
frame.setSize(600, 400);
//for the size of the box
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);
}
}

In: Computer Science

TCP Wireshark Lab – Working with a remote server.  You will go through the steps below, use...

TCP Wireshark Lab – Working with a remote server.  You will go through the steps below, use your captured wireshark file and the provided wireshark file (on D2L) to answer the questions.  When you have finished the lab you will submit the following:

  1. This document with your answers provided in the appropriate places.  
  2. Your wireshark capture file as a zipped file.  

STEPS:

1. Start up your web browser. Go thehttp://gaia.cs.umass.edu/wireshark-labs/alice.txtand retrieve an ASCII copy of Alice in Wonderland. Store this file somewhere on your computer.

2. Next go to http://gaia.cs.umass.edu/wireshark-labs/TCP-wireshark-file1.html.

3. Use the Browse button in this form to enter the name of the file (full path name) on your computer containing Alice in Wonderland (or do so manually). Don’t press the “Upload alice.txt file” button, yet!

4. Now start up Wireshark and begin packet capture (Capture->Start) and then press OK on the Wireshark Packet Capture Options screen (we’ll not need to select any options here).

5. Returning to your browser, press the “Upload alice.txt file” button to upload the file to the gaia.cs.umass.edu server. Once the file has been uploaded, a short congratulations message will be displayed in your browser window.

6. Stop Wireshark packet capture and save your capture file. Your Wireshark window should look similar to the window shown below.

———————————————————————————————————————————————————————-

PART 2: A first Look At the Captured Trace  

Use the provided online capture (uploaded in D2L as a zip file – you will need to extract it before opening in Wireshark) to answer the following:

1. What is the IP address and TCP port number used by the client computer (source) that is transferring the file to gaia.cs.umass.edu? To answer this question, it’s probably easiest to select an HTTP message and explore the details of the TCP packet used to carry this HTTP message, using the “details of the selected packet header window”.  (5 pts answer, 5 pts explanation of which packet # you used to answer this question)

2. What is the IP address of gaia.cs.umass.edu? On what port number is it sending and receiving TCP segments for this connection? (5 pts for answer, 5 pts for explanation of which packet # )

Use your own Captureto answer the following:

3. What is the IP address and TCP port number used by your client computer (source) to transfer the file to gaia.cs.umass.edu? (10 pts – with screenshot of your capture)

———————————————————————————————————————————————————————-

PART 3: TCP Basics

4. What is the sequence number of the TCP SYN segment that is used to initiate the TCP connection between the client computer and gaia.cs.umass.edu? What is it in the segment that identifies the segment as a SYN segment? (5 pts for answer, 5 pts for packet #)

5. What is the sequence number of the SYNACK segment sent by gaia.cs.umass.edu to the client computer in reply to the SYN? What is the value of the Acknowledgement field in the SYNACK segment? How did gaia.cs.umass.edu determine that value? What is it in the segment that identifies the segment as a SYNACK segment? (5 pts for answer , 5 pts for screenshot of highlighted packet)

6. What is the sequence number of the TCP segment containing the HTTP POST command? Note that in order to find the POST command, you’ll need to dig into the packet content field at the bottom of the Wireshark window, looking for a segment with a “POST” within its DATA field. (5 pts for answer, 5 pts for screenshot of highlighted packet)

7. Consider the TCP segment containing the HTTP POST as the first segment in the TCP connection. What are the sequence numbers of the first six segments in the TCP connection (including the segment containing the HTTP POST)? At what time was each segment sent? When was the ACK for each segment received? (10 pts)

8. What is the length of each of the first six TCP segments? (10 pts)

9. What is the minimum amount of available buffer space advertised at the received for the entire trace? Does the lack of receiver buffer space ever throttle the sender? (10 pts)

10. Are there any retransmitted segments in the trace file? What did you check for (in the trace) in order to answer this question? (10 pts)

———————————————————————————————————————————————————————-

PART 4: TCP Congestion Control In Action

STEPS:

1. Select a TCP segment in the Wireshark’s “listing of captured-packets” window. Then select the menu : Statistics->TCP Stream Graph-> Time-SequenceGraph(Stevens).  

QUESTIONS:

Answer Question 11 Using the provided Capture (Bonus: 10 pts)

11. Use the Time-Sequence-Graph(Stevens) plotting tool to view the sequence number versus time plot of segments being sent from the client to the gaia.cs.umass.edu server. Can you identify where TCP’s slowstart phase begins and ends, and where congestion avoidance takes over? Insert a screenshot of your Time-Sequence-Graph and explain your answer.

In: Computer Science

In JAVA: Create a circular doubly linked list. It need not be generic. Implement addToStart and...

In JAVA:

Create a circular doubly linked list. It need not be generic. Implement addToStart and addToEnd methods, as well as printList method. Implement delete(Node n) method that deletes a node n, if n is in the linked list. Make no assumptions about n. Test your linked list.

In: Computer Science

1. What is exception handling? 2. Name a few common types of exceptions.

1. What is exception handling?

2. Name a few common types of exceptions.

In: Computer Science

Subject: Computer Algorithms 3) Design an efficient algorithm that sorts an array containing 2 sorted sets...

Subject: Computer Algorithms

3) Design an efficient algorithm that sorts an array containing 2 sorted sets of numbers, such as A=[3,4,7,9,13,1,5,6,8] (Note that [3,4,7,9,13] and [1,5,6,8] are both sorted, but A is not). Your algorithm declaration should look like this:

MYSORT(A,p,n)

where A is the input array, p is the index to the first element of the second set of numbers, and n is the length of array A.

Calculate the asymptotic running time and space of you algorithm.

Reference book

Introduction to Algorithms 3rd edition

Ebook URL:

http://ce.bonabu.ac.ir/uploads/30/CMS/user/file/115/EBook/Introduction.to.Algorithms.3rd.Edition.Sep.2010.pdf

In: Computer Science

IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the...

IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the (integer) grades they earned in 3 tests. It then outputs the average grade for each student. It also outputs the highest grade a student earned in each test, and the average of all grades in each test.

Your output should look like this:

Mary's average grade was 78.8%

Harry's average grade was 67.7%

etc... :

In test 1 the highest grade was 93% and the average was 89.2%

In test 2........etc

Your main method should be modular.

Write a method that inputs the 5 names into an array (one dimensional), and returns this array to main

Write a method that inputs the 15 (integer) test grades into a (two-dimensional) array, and returns this array to main.

Write a method that calculates the students averages and stores them in an array , and returns this array to main

Write a method that calculates the average grade for each test and stores them in an array, and returns this array to main

Write a method that determines the highest grade for each test and stores this in an array , and returns this array to main. MAIN will print all the information. The printing could be done easily by the methods instead of having to store the information in an array, but this will give you practice in arrays and methods - all useful for the final exam.

Thanks a lot, please include the comments.

In: Computer Science

Describe and explain at least three improvements you think came about with the introduction of intrusion...

Describe and explain at least three improvements you think came about with the introduction of intrusion prevention technology. Justify your response with at least one credible source.

Explain which of these features you would consider to be the most beneficial if you were a member of the IT team supporting a network. Justify your response with at least one credible source.

In: Computer Science

C++ I am a beginner at this and have a hard time with for loops.. I...

C++
I am a beginner at this and have a hard time with for loops.. I was given this prompt.


part 1.
1. Create an array to store 8 characters.
2. Using a for loop, get an 8-letter word from the user, one letter at a time.
3. Then use another for loop to print the complete word onto the screen one letter at a time.
4. Then use a third for loop to print out the word backwards.

part 2.
Write a function that takes your array of characters and a single character and searches through the array cell by cell for the specified character. If found, display the index at which the letter was found; if not, display a message stating that the character array does not contain that letter.
​void find (char letters [ ], int size, char c)

In: Computer Science

Implement these methods (adjust DoubleList.java only for errors if you think needed): getNode – take in...

Implement these methods (adjust DoubleList.java only for errors if you think needed):

getNode – take in one int parameter indicating the index of the node to retrieve (index 0 is the front). If that index is out of the bounds of the list, throw a DoubleListException with an appropriate message. Otherwise, determine which half of the list the index is in, and traverse to it using the shortest traversal to get there, by calling either traverseForwards or traverseBackwards with the number of steps to get to the index from the corresponding end (if it's the very middle, you can decide which way to go). For example, consider a list with 5 nodes. Calling getNode(1) should retrieve the node immediately after front using traverseForwards. Calling getNode(3) should retrieve the node immediately after rear using traverseBackwards. Return the found node.

setElement – take in two input parameters: index (int) and element (generic type). Call the getNode method described below to find the node to be updated, and then called setElement on that node with the given element

getElement – take in one input parameter: index (int). Call the getNode method with the given index and return the data element of the node at that position.

toString – returns the string representing the list from the front to the rear with a space between each node. If the list is empty, then return the string "Empty list".

DoubleNode.java

public class DoubleNode{

private DoubleNode next;

private DoubleNode previous;

private T element;

/**

* Constructor with no input parameters.

*/

public DoubleNode(){

next = null;

previous = null;

element = null;

}

/**

* Constructor with one input parameter representing the node's data element.

* @param elem

*/

public DoubleNode (T elem){

next = null;

previous = null;

element = elem;

}

/**

* Get the next node.

* @return next node

*/

public DoubleNode getNext(){

return next;

}

/**

* Get the previous node.

* @return previous node

*/

public DoubleNode getPrevious(){

return previous;

}

/**

* Set the next node.

* @param node

*/

public void setNext (DoubleNode node){

next = node;

}

/**

* Set the previous node.

* @param node

*/

public void setPrevious (DoubleNode node){

previous = node;

}

/**

* Get the data element.

* @return data element.

*/

public T getElement(){

return element;

}

/**

* Set the data element.

* @param elem

*/

public void setElement (T elem){

element = elem;

}

/**

* Return the node's data element for printing purposes.

* @return string of node's data element

*/

public String toString () {

return element.toString();

}

}

DoubleList.java

public class DoubleList{

DoubleNode front,rear;

private T count;

public DoubleList () {

front = null;

rear = null;

count = 0;

}

public void addToRear(T elem){

DoubleNode new_node = new DoubleNode(elem);

if (front.getElement() == null){

front.setElement(new_node);

rear.setElement(new_node);

} else if (front.getElement() != null){

new_node.setPrevious(rear);

rear.setNext(new_node);

rear = new_node;

}

count = count + 1;

}

public void traverseForwards(T elem){

DoubleNode numNode = new DoubleNode(elem);

curNode = front.getElement();

for (i = 0; i = numNode; ++i){

System.out.println(curNode);

curNode = curNode.getNext();

} if (front.getElement == null){

System.out.println(null);

}

}

public void traverseBackwards(T elem){

DoubleNode numNode = new DoubleNode(elem);

curNode = rear.getElement();

for (i = 0; i = numNode; ++i){

System.out.println(curNode);

curNode = curNode.getPrevious();

} if (rear.getElement == null){

System.out.println(null);

}

}

In: Computer Science

Program 4(Total Point 15): You will use the scanner class and ask users following things. -...

Program 4(Total Point 15): You will use the scanner class and ask users following things.

- Student Age (Value)

- Student Name (Key)

You will store information for at least 10 students on Map. You will then use iterator to print all the values. You will print the youngest student’s name.

In: Computer Science

You need to write and run C programs (as processes on your Linux machine), and monitor...

You need to write and run C programs (as processes on your Linux machine), and monitor their behavior. Consider the following problem: A program is to be written to print all numbers between 1 and 1000 (inclusive) that are not (evenly) divisible by either 2 or 3. This problem is to be solved using three processes (P0, P1, P2) and two one-integer buffers (B0 and B1) as follows:  P0 is to generate the integers from 1 to 1000, and place them in B0 one at a time. After placing 1000 in the buffer, P0 places the sentinel 0 in the buffer, and terminates.  P1 is to read successive integers from B0. If a value is not divisible by 2, the value is placed in B1. If the value is positive and divisible by 2, it is ignored. If the value is 0, 0 is placed in B1, and P1 terminates.  P2 is to read successive integers from B1. If a value is not divisible by 3, it is printed. If the value is positive and divisible by 3, it is ignored. If the value is 0, P2 terminates. Write a program to implement P0, P1, and P2 as separate processes and B0 and B1 as separate pieces of shared memory {each the size of just one integer}. Use semaphores to coordinate processing. Access to B0 should be independent of access to B1; for example, P0 could be writing into B0 while either P1 was writing into B1 or P2 was reading.

In: Computer Science

************CODING IN C++ ONLY ******************** Instructions Write a function, remove, that takes three parameters: an array...

************CODING IN C++ ONLY ********************

Instructions

Write a function, remove, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, removeItem).

The function should find and delete the first occurrence of removeItem in the array. (Note that after deleting the element, the number of elements in the array is reduced by 1.) Assume that the array is unsorted. Also, write a program to test the function.

Your program should prompt the user to enter 10 digits for the array. Display the starting array to the user and prompt them to select an integer to remove. After the selected integer has been removed, the updated list should be displayed to the user. If the value does not exist or the array is empty, output the following message: x is not in the list

GRADING CRITERIA

1)  Defined the remove function

2) Removing elements from the list

3) List does not contain integer to be removed

TESTING WITH INPUT

2
7
6
8
3
9
10
1
5
4
6

OUTPUT SHOULD BE

2 7 8 3 9 10 1 5 4

*************************************

A SAMPLE OF MY CODE, IT HAS MANY ERRORS

#include <iostream>
using namespace std;

void remove(int arrayList[],int& size,int removeItem)
{
int i, j;
for (i = 0; i < size; i++)
if (arrayList[i] == removeItem)
if(i == size-1)
{
//decrease items
size--;
return;
}
else
{
for (j = i; j < size-1; j++)
arrayList[j] = arrayList [j+1];
size --;
return;
}
cout <<" item" << remove item << is not found in the array";
}

In: Computer Science

In C++ First create the txt file given below. Then complete the main that is given....

In C++

First create the txt file given below. Then complete the main that is given. There are comments to help you. An output is also given You can assume that the file has numbers in it

Create this text file: data1.txt

-59 -33 34 0 69 24 -22 58 62 -36 
5 45 -19 -73 62 -5 95 42 

Main

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

const int MAXSIZE = 100;

// Prototypes





int main()
{
    int nums[MAXSIZE];
    int searchFor;
    int indexFound = -1;
    int numElems;
    double average;
    string fileName;
    char again;

    do
    {

        cout << "Enter the file name: ";
        cin >> fileName;

        // Call the function fillArray. It has the fileName, the nums array and
        // the numElem passed in (in that order). It will calculate the numElems
        // Description of function given below



        // Call the function printArray. It has the nums array and
        // the numElem passed in (in that order). 
        // Description of function given below





        // Call the function findAverage. It has the nums array and
        // the numElem passed in (in that order). It stores the value
        // that is returned in the average variable declared above.
        // Description of function given below




        // Asks the user what number they want to search for
        cout << endl << endl;
        cout << "Enter a number between -100 and 100 to search for: ";
        cin >> searchFor;

        // Call the function findValue. It has the number being searched for
        // the nums array and the numElem passed in (in that order). 
        // It stores the index of the position in the array where the 
        // number was found in the indexFound variable declared above.
        // Description of function given below



        // Right the if statement to print whether the number was found.
        // If it was found, it will print the inde of where it was found.
        // (See output for what should be printed






        cout.setf(ios:: fixed);
        cout.precision(2);
        cout << "The average of all the numbers in the array is " << average << endl;
        cout << endl;
        cout << "Do you want to do this again? (Y/N): ";
        cin >> again;
    } while (toupper (again) == 'Y');
    return 0;
}



// Function: findValue
// This function has the value being serachedd for, the array and the number of 
// elements passed in. I searches the array and when it first finds it, it
// stops searching and returns the index of where it was found. If it is not 
// in the array, it returns a -1






// Function: findAverage
// This function has the array and the number of elements passed in.
// It computes the average of the numbers in the array and returns it.






// Function: printArray
// This function has the array and the number of elements passed in.
// It prints the array in neat columns, with 7 numbers per line







// Function: fillArray
// This function should open the file with the name that passed into it. If the file does
// not open correctly it should exit the program. It should
// then read in the numbers and load them into the array. 
// make sure you check that you don't exceed the array size.
// If the file has too many numbers, your program should not put the 
// extra numbers in the array, the array will just be full.
// This function determines the number of elements in the array.
// This function should not call any other user defined functions.

Sample Output

Enter the file name: data.txt
    -59    -33     34      0     69     24    -22
     58     62    -36      5     45    -19    -73
     62     -5     95     42

Enter a number between -100 and 100 to search for: 62
62 was found in index 8
The average of all the numbers in the array is 13.83

Do you want to do this again? (Y/N): Y
Enter the file name: data1.txt
    -59    -33     34      0     69     24    -22
     58     62    -36      5     45    -19    -73
     61     -9     95     42    -73    -64     91
    -96      2     53     -8     82    -79     16
     18     -5    -53     26     71     38    -31
     12    -33     -1    -65     -6      3    -89
     22     33    -27    -36     41     11    -47
    -32     47    -56    -38     57    -63    -41
     23     41     29     78     16    -65     90
    -58    -12      6    -60     42    -36    -52
    -54    -95    -10     29     70     50    -94
      1     93     48    -71    -77    -16     54
     56    -60     66     76     31      8     44
    -61    -74     23     37     38     18    -18
     29     41

Enter a number between -100 and 100 to search for: 52
The number 52 was not found in the array
The average of all the numbers in the array is 1.48

Do you want to do this again? (Y/N): y
Enter the file name: data.txt
    -59    -33     34      0     69     24    -22
     58     62    -36      5     45    -19    -73
     62     -5     95     42

Enter a number between -100 and 100 to search for: 95
95 was found in index 16
The average of all the numbers in the array is 13.83

Do you want to do this again? (Y/N): n

In: Computer Science

In python language do thee following: Some password scheme is designed such that the password must...

In python language do thee following:

Some password scheme is designed such that the password must start with a special symbol in “$” “@” or “!” followed by four letters that could be in a..z followed by a similar special symbol followed by three letters in A..Z followed by a single digit. Write a program that takes from the user a string, and verifies whether the string abides by this password scheme. Do this once using regular expressions. Another time without using regular expressions.

In: Computer Science