Bash scripting return output: Determine the output this code
1. #!/bin/bash
Valid = true
count=1
while [ $valid ]
do
echo $count
if [ $count -eq 5 ];
then
break
fi
((count++))
done
2. #!/bin/bash
num=100
for x in $(seq 1 5)
do
temp=$((num+x))
if [ $temp -1e 103]; then
echo $temp
else
echo "Too Big"
fi
done
3.#!/bin/bash
num=5
for x in $(seq 1 5)
do
echo $((num*x))
done
4. #!/bin/bash
for x in $(seq 1 10)
do
echo $x
done
5. line 1
line 2
line 3
line 4
line 5
head -n4 < data.txt > t1.txt
tail -n1 <t1.txt > out.txt
cat out.txt
In: Computer Science
Write a program that solves the Knapsack problem. Code to the following standards.
Your source of items to put into the knapsack should consist of five randomly generated integers in the range of 1 to 20.
Your knapsack can hold 20 lbs.
In: Computer Science
Directions:
Write a C++ program that will create an array of four integers.
It will allow the user to enter in four valid scores and store them in the array. ( valid range is 0 - 100)
It will compute the letter grade based upon the four scores, namely, A = 90 - 100, B= 80- 89, C = 70-79, D = 60-69, otherwise F.
It will display the scores and letter grade to the screen.
NOTE: No menu is required.
2. Write a function called inputData that takes in a pointer to the array of integers as a parameter, prompts the user for four valid score values and stores these values in the array of integers. (15 points).
4. Write a function called calcGrade that takes in a pointer to the array of integers as a parameter, computes and returns the letter grade based upon the scale listed above. (15 points).
5. Write a function called displayResults that takes in a pointer to the array of integers and the character letter grade as a parameters, computes, and displays these values in the format shown in the sample run below. (15 points).
6. Add comments wherever necessary. (5 points)
Sample Runs:
NOTE: not all possible runs are shown below.
Run 1:
Welcome to the compute letter grade program
Test score 1: Please enter in a score...-9
Please enter in a score (0-100)...999
Please enter in a score (0-100)...90
Test score 2: Please enter in a score...98
Test score 3: Please enter in a score...96
Test score 4: Please enter in a score...95
Test 1: 90
Test 2: 98
Test 3: 96
Test 4: 95
Grade : A
Run 2:
Welcome to the compute letter grade program
Test score 1: Please enter in a score...90
Test score 2: Please enter in a score...70
Test score 3: Please enter in a score...85
Test score 4: Please enter in a score...76
Test 1: 90
Test 2: 70
Test 3: 85
Test 4: 76
Grade : B
General Requirements:
1) Include the header comment with your name and other information on the top of your files.
2. Please make sure that you're conforming to specications (program name, print statements, expected inputs and outputs etc.). Not doing so will result in a loss of points. This is especially important for prompts. They should match mine EXACTLY.
3. If we have listed a specication and allocated point for it, you will lose points if that particular item is missing from your code, even if it is trivial.
4. No global variables (variables outside of main() ) unless they are constants.
5. All input and output must be done with streams, using the library iostream
6. You may only use the iostream and iomanip libraries. Including unnecessary libraries will result in a loss of points.
7. NO C style printing is permitted. (Aka, don't use printf). Use cout if you need to print to the screen.
8. When you write source code, it should be readable and well-documented (comments).
9. Make sure you either develop with or test with CLion (to be sure it reports no compile errors or warnings!) before you submit the program.
In: Computer Science
Database Design - Recovery
Choose a database recovery problem and then propose a solution using the techniques such as Log-based recovery, shallow paging, etc.
Briefly describe the technique, when it is appropriate to use and what recovery problem it solves.
In: Computer Science
Choose one HTML5 API in the W3Cs HTML5 specification. In your own words, describe what this particular API does and give an example of how it can be used within a Web page. Please type out in text, as handwriting is often hard to read. Be as detailed as possible please. Thank you in advance!
In: Computer Science
This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team.
(1) Prompt the user to input five pairs of numbers: A player's
jersey number (0 - 99) and the player's rating (1 - 9). Store the
jersey numbers in one int array and the ratings in another int
array. Output these arrays (i.e., output the roster). (3 pts)
Ex:
Enter player 1's jersey number: 84 Enter player 1's rating: 7 Enter player 2's jersey number: 23 Enter player 2's rating: 4 Enter player 3's jersey number: 4 Enter player 3's rating: 5 Enter player 4's jersey number: 30 Enter player 4's rating: 2 Enter player 5's jersey number: 66 Enter player 5's rating: 9 ROSTER Player 1 -- Jersey number: 84, Rating: 7 Player 2 -- Jersey number: 23, Rating: 4 ...
(2) Implement a menu of options for a user to modify the roster.
Each option is represented by a single character. The program
initially outputs the menu, and outputs the menu after a user
chooses an option. The program ends when the user chooses the
option to Quit. For this step, the other options do nothing. (2
pt)
Ex:
MENU u - Update player rating a - Output players above a rating r - Replace player o - Output roster q - Quit Choose an option:
(3) Implement the "Output roster" menu option. (1 pt)
Ex:
ROSTER Player 1 -- Jersey number: 84, Rating: 7 Player 2 -- Jersey number: 23, Rating: 4 ...
(4) Implement the "Update player rating" menu option. Prompt the
user for a player's jersey number. Prompt again for a new rating
for the player, and then change that player's rating. (1 pt)
Ex:
Enter a jersey number: 23 Enter a new rating for player: 6
(5) Implement the "Output players above a rating" menu option.
Prompt the user for a rating. Print the jersey number and rating
for all players with ratings above the entered value. (2 pts)
Ex:
Enter a rating: 5 ABOVE 5 Player 1 -- Jersey number: 84, Rating: 7 ...
(6) Implement the "Replace player" menu option. Prompt the user
for the jersey number of the player to replace. If the player is in
the roster, then prompt again for a new jersey number and rating.
Update the replaced player's jersey number and rating. (2
pts)
Ex:
Enter a jersey number: 4 Enter a new jersey number: 12 Enter a rating for the new player: 8
C language
In: Computer Science
LEVEL ONE
Hint: Use the inline for and range().
Hint: Explore the for … if … statement.
LEVEL TWO
Hint: Explore numpy.random.rand().
NB: THIS IS A PYTHON ASSIGNMENT
In: Computer Science
In: Computer Science
Using Python.
A file exists on the disk named students.txt. The file contains
several records, and each record contains two fields: (1) the
student’s name, and (2) the student’s
score for the final exam. Write code that deletes the record
containing “John Perz”as the student name.
This the code i have so far but it's not working:
import os
def main():
found=False
search='John Perz'
student_file = open('student.txt','r')
temp_file = open('temp_students.txt','w')
name=student_file.readline()
score=''
while name !='':
score=student_file.readline()
name=name.rstrip('/n')
score=score.rstrip('/n')
if name !=search:
temp_file.write(name+'/n')
temp_file.write(score+'/n')
else:
found=True
name=student_file.readline()
student_file.close()
temp_file.close()
os.rename('temp.text','student.text')
if found:
print("The record was deleted")
else:
print("Record not found")
main()
In: Computer Science
Using the buildHeap method, write a sorting function that can sort a list in O(nlogn) time.
def buildHeap(self,alist): i = len(alist) // 2 self.currentSize = len(alist) self.heapList = [0] + alist[:] while (i > 0): self.percDown(i) i = i - 1
Base on this code please
In: Computer Science
1.Which of the following statements about endpoint solution is true?(choose one or more)
A. Similar to network based monitoring, encryption can be an obstacle for endpoint based monitorinng
B. Endpoint agents can actively prevent attacks in realtime
C. Network based monitoring can be simpler to deploy than endpoint monitoring because it can concentrate on a few network appliannces
D. Endpoint agents can monitor application programs, users, as well as network activities
2. Which of the following windows events typically deserve high security alert by itself?
A. Logclearing
B. User added to global admin group
C. Modification of HKLM registration nkey
D. New admin user creation
3.Which of the following windows events have the highest security risk?
A. Received a power operations request
B. Host has successfully loaded driver
C. Received request to load driver
D. New USB device plugged in
4.Which of the following are important to detect pass-the-hash attacks?(choose one or more)
A. Monitor new service creationnns
B. Enterprise-wide norm: use token based authentication such as Kerberos
C. Monitor modifications to HKLM/HKCU keys
D. Monitoring susscessful logon eventsw
5. Which of the following endpoint events might be generated by malicious activities in the "installation" phase of the kill chain?(choose one or more)
A. User added to global admin group
B. New user created
C. New service created
D. modifications to HKLM/HKCU
In: Computer Science
Are my codes correct?
#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <ctype.h>
#include<fstream>
int locateMinimum( const std::string array[ ], int n ){
if(n <= 0){
return -1;
}
else{
int minInd = 0;
for(int i = 0; i < n; ++i){
if(array[i] < array[minInd]){
minInd = i;
}
}
return minInd;
}
}
int countPunctuation( const std::string array[], int n)
{
int count = 0;
for (int i=0;i<= n;i++)
{
if (array[i]== ('!', ',' ,':' ,';' ,'.', '-' ,'?'))
{
count = count + 1;
return count;
}
else {
return 0;
}
bool hasReverse(const std::string array[ ], int n )
{
// entire array
for(int i=0;i<n;i++)
{
//finding the reverse of the string
string rev = string(array[i].rbegin(),array[i].rend());
//checking that reverse of the string is present in the array or not
//if present returning true or we are returning false
for(int j=0;j<n;j++)
{
if(array[j] == rev){
return true;
}
}
}
return false;
}
char highestOccurredCharacter(const std::string array[ ], int n, int index ){
if( n <= 0 || index >= n || index < 0) //if invalid array length n or invalid index is given the function returns null character
return '\0';
int highest=0; //initially considering the highest to be 0
char c = '\0'; //to save the most repeating character
for(int i=0;i<array[index].length();i++){ //traversing through the string array[index]
int count = 0; //initial count of character array[index][i] is 0
for(int j=0;j<array[index].length();j++) //traversing through the string array[index] again to find the count of repeatetions of array[index][i] character
if(array[index][i]==array[index][j])
count++;
if(count>highest){ //if count is greater than the highest count then we have a new highest which has to be stored in highest
highest = count; //save the latest highest in highest
c = array[index][i]; //save the character of latest highest in c
}
}
return c; //return the total highest repeated character
}
bool isInIncreasingOrder( const std::string array[ ], int n )
{
if(n < 0){
return false;
}
else if(n == 0){
return true;
}
else{
for(int i = 1; i < n; ++i){
if(fruit[i] <= fruit[i - 1]){
return false;
}
}
return true;
}
}
char firstNonRepeatedCharacter(const std::string array[ ], int n, int index);
//This function finds out the first non repeating chracter and returns it
if( n <= 0 || index>= n || index < 0) { //if invalid array length n or invalid index is given the function returns null character
return '\0';}
for(int i=0;i<array[index].length();i++){ //traversing through the string array[index] chracters
int count = 0; //initialising count to 0 initially
for(int j=0;j<array[index].length();j++) //traversing through the string array[index] chracters to count the occurrences
if(array[index][i]==array[index][j]) //
count++;
if(count==1) //the count of non Repeating Character is 1 so if any chracter gets a count 1 it must be returned and it would be the firstNonRepeatedCharacter
return array[index][i];
}
bool isOnlyDigits( const std::string array[ ], int n ){
//traversing array
for(int i=0;i<n;i++)
{
//traversing each string of the array
for(int j=0;j<array[i].length();j++)
{
//checking the string contains only digits or not if not we are returning false
if (!(array[i][j] >= '0' && array[i][j] <= '9'))
return false;
}
}
return true;
}
}
In: Computer Science
HAVE a script to display random images every time you click the browser's refresh button.
(Just need a script code(s) to add to the default code that will display random images every time you click the browser's refresh button.
DEFAULT CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Student's Information</title>
</head>
<body>
<table align ="center" width ="70%">
<tr>
<td colspan ="2">
<h1> </h2>
<h1>Student's Information</h1>
<p><input type="button" id="students" value="Enter Data" /></p>
</td>
</tr>
</table>
</body>
</html>
In: Computer Science
For this assignment you are to write both the server and client
applications for a Knock-Knock joke system based on the Java TCP
socket client-server example that has been discussed in lectures.
The joke protocol goes like this:
Client: "Tell me a joke."
Server: "Knock knock!"
Client: "Who's there?"
Server: "Witches."
Client: "Witches who?"
Server: "Witches the way to the store."
Client: "Groan."
The Client
The client code should connect to the joke server and allow the user to type in responses, like in the above example. To initiate the joke server, an initial request line must be fed to the server. The input sentences are sent to the server and processed and responded to by the server. The client code should then print the server response and allow for the next input from the user. Once the punchline has been delivered, the user will react and the client code will terminate the connection and the application.
The Server
The server code will wait for a client to connect on the designated port. When a client connection is made and upon receipt of an acceptable initial request, the server will make an initial response of "Knock, Knock!" to the client. Your server should have at least 5 jokes stored up (pairs of names and corresponding punchlines) and randomly choose one to feed to the client when the appropriate request line is received from the client. Once the punchline is delivered, a reaction from the client is accepted and the server is then able to terminate the connection and wait for a new client request.
If the expected response is not given, an appropriate error/prompting message is to be sent back to the client app in order to get the user running the client to put in the expected next line of the joke protocol. For debugging and/or logging purposes, the server should, at least, print to the console some indication of which joke has been selected.
Example:
Server: "Knock knock!"
Client: "What do you want?"
Server: "No, no, you're supposed to say 'Who's
there?'"
In: Computer Science