Examine the following shell script and describe its function line-by-line:
#! /bin/bash
#This script backs up the Oracle DB
rm -f /SAN/backup-oracle*
if tar -zcvf /SAN/backup-oracle- 'date +%F'.tar.gz/oracledb/*
then
echo "Oracle backup completed on 'date'" >>/var/log/oraclelog
else
echo "Oracle backup failed on 'date'" >>/var/log/oraclelog
mail -s ALERT [email protected] </var/log/oraclelog
fi
In: Computer Science
What can a company do to ensure that its IT architecture and infrastructure are secure? Discuss specific tasks that can be done to help manage risk.
In: Computer Science
This program is used to split the input based on the delimiter. Change the code below so that the parse function should return an array that contains each piece of the word. For example, the input to the function would be something like 'aa:bbbA:c,' which would be a char *. The function's output would then be a char ** where each element in the array is a char *. For this example, it would return some result where result[0] = 'aa', result[1] = 'bbbA', and result [2] = 'c'. So instead of doing the printing in the parse func, return each piece of the word, pass it to the main function, then do the printing in the main
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void parsefunc (char, char*);
int string_length (char*);
char* my_strncpy (char*, const char*, unsigned int);
//Main Fucntion
int main(int argc, char *argv[] ) {
if(argc == 1 || argc == 2){
printf("Not enough arguments,
please enter three agruments with program name, delimiter and text!
\n");
}
else{
parsefunc(*argv[1], argv[2]);
}
}
//This function is used to splip up the string and print the
results
void parsefunc(char delimeter, char *input){
int count = 0;
int current = 0;
int length = strlen(input);
//Loop through the string
for (int i = 0; i < length; i++){
//Check for delimiter
if(input[i] == delimeter){
char* tempString = malloc(sizeof(char) * (count + 1));
strncpy(tempString, input+current, count);
tempString[count+1] = '\0';
//printf("%d\n", current);
current += count+1;
printf("%s Length %d\n", tempString, count);
count = 0;
free(tempString);
}
//Check for delimiter
else if(input[i+1] == '\0'){
char* tempString = malloc(sizeof(char) * (count + 1));
strncpy(tempString, input+current, count+1);
tempString[count+1] = '\0';
//printf("%d\n", current);
current += count+1;
printf("%s Length %d\n", tempString, count+1);
free(tempString);
}else{
count++;
}
}
}
In: Computer Science
Discuss in detail at least one of the key network functions.
In: Computer Science
I need a program which tells me if three individual straight line segments form a plane two-dimensional triangle. All three segments will have positive lengths. For example, the three segments 2.5, 3.4 and 5.3 will form a triangle but 1.7, 2.4 and 7.5 will not. If the user enters a zero value, it will be rejected. But if a negative number is entered, it will be changed to the corresponding positive value. Please keep in mind that the length of the longest segment must be less than the sum of the lengths of the other two segments.
The program will accept the three lengths of the segments using the iostream acceptance and testing syntax. Then, it will use a C++ class and a C++ object of that class to find the longest of the three segments and to test whether the three segments will form a triangle. If the three segments will form a triangle the method of your class will return the Boolean value true to the program’s main. Otherwise, it will return the Boolean value false to the program’s main. Then the program’s main will report the result as a text answer to the user, either “true” or “false” and then terminate.
In: Computer Science
In: Computer Science
Build the 7-segment decoder for BCD using a ROM (in logisim)
In: Computer Science
A graph consists of nodes and edges. An edge is an (unordered) pair of two distinct nodes in the graph. We create a new empty graph from the class Graph. We use the add_node method to add a single node and the add_nodes method to add multiple nodes. Nodes are identified by unique symbols. We call add_edge with two nodes to add an edge between a pair of nodes belonging to the graph. We can also ask a graph for the number of nodes and edges it contains, and for a list of its nodes and edges. The to_s method returns a string representing the graph's adjacency lists. Methods should not change the graph if called with invalid arguments; e.g., adding an edge that is already in the graph or that references a node that does not already belong to the graph. Your code does not have to generate the exact transcript that follows but it should provide this basic functionality.
>> g = Graph.new => >> g.add_node(:a) => a
>> g.add_nodes([:b, :c]) => [:b, :c]
>> g
=>
>> g.get_nodes => [:a, :b, :c] >> g.nbr_nodes => 3
>> g.add_edge(:a, :b) => [a, b]
>> g.add_edge(:b, :c) => [b, c]
>> g => >> g.get_edges => [[a, b], [b, c]]
>> g.nbr_edges => 2 >> puts g a -> b
b -> a,c c -> b => nil
please I want the code in( Ruby) not another language
In: Computer Science
04 Prove : Homework - Data Structures
Linked Lists
Outcomes
At the end of this study, successful students will be
able to:
Articulate the strengths and weaknesses of Linked
Lists.
Use Linked Lists in Python to solve
problems.
Preparation Material
Read the following sections from Wikipedia: Linked
Lists:
The Introduction
Advantages
Disadvantages
Basic concepts and nomenclature
The following subsections are sufficient:
Intro
Singly Linked Lists
Doubly Linked Lists
Tradeoffs
The following subsections are sufficient:
Linked Lists vs. Dynamic Arrays
Data Structures for the Common Person
After going over the technical details of linked lists
above, please watch the following short video, containing a
non-computing example:
Using Linked Lists in Python
Many languages have a LinkedList library that provides
all of this behavior for you. Python does not specifically have a
"LinkedList" collection. It does, however, have a deque
(Double-ended queue, pronounced "deck"), which is in fact
implemented as a doubly-linked list (see: StackOverflow).
The Deque is a generalization of stacks and queues
(which we will learn about in future weeks), but provides all the
functionality we would expect from a LinkedList, with O(1)
insertion and removal from the beginning and end of the list, and
O(n) retrieval of an item at a specific index. See the Python
documentation for a list of available methods, but in
short:
append(x) - Adds x to the end of the list
appendleft(x) - Adds x to the beginning of the
list
insert(i, x) - Inserts x at index i
pop() - Removes and returns the last item in the
list
popLeft() - Removes and returns the first item in the
list
In addition, you can iterate over a deque, using a for
loop, just like a list:
from collections import deque cars = deque() cars.append("Ford")
cars.append("Mazda") cars.append("Dodge") for car in cars:
print(car)
And, you technically can use the index notation
to access and object (e.g., print(cars[2]), but remember, this is
an O(n) operation, so if we are wanting to do this much, a linked
list may not be the right choice.
Homework Assignment
Use a linked list (i.e., a Python deque) to keep track
of a playlist of songs. Your playlist should have the functionality
to add songs to the end of the list, insert a new one at the first
of the list (so that it is played next), and then to play a song
(which removes it from the list).
INSTRUCTIONS
Follow these steps to help guide you through the
assignment:
Create a Song class that has member variables for a
title and an artist. It should have a prompt function that asks the
user for the title and artist, and a display function that displays
the title and the artist to the screen.
Create a deque of songs for your playlist.
Set up a main loop that asks the user for one of the
following options:
Add new song to the end of the playlist.
Insert a new song at the beginning of the playlist (so
it will play next).
Play a song (this should remove it from the
playlist).
Implement each of the above actions. For the ones that
add a new song, it should prompt the user for the values, and then
add the song to the play list.
When the user selects the option to play a song, it
should be removed from the list. Then, display a message to the
user, "Playing song:", followed by the title and the artist of the
song that was just removed from the front of the
playlist.
If the user attempts to play a song and the playlist
is empty, they should receive a message that informs them the
playlist is empty, and then they can make another selection. (A
Python error message should not occur and be displayed.)
EXAMPLE OUTPUT
Options: 1. Add a new song to the end of the playlist 2. Insert a
new song to the beginning of the playlist 3. Play the next song 4.
Quit Enter selection: 3 The playlist is currently empty. Options:
1. Add a new song to the end of the playlist 2. Insert a new song
to the beginning of the playlist 3. Play the next song 4. Quit
Enter selection: 1 Enter the title: Let it Be Enter the artist: The
Beatles Options: 1. Add a new song to the end of the playlist 2.
Insert a new song to the beginning of the playlist 3. Play the next
song 4. Quit Enter selection: 2 Enter the title: The Sound of
Silence Enter the artist: Simon and Garfunkel Options: 1. Add a new
song to the end of the playlist 2. Insert a new song to the
beginning of the playlist 3. Play the next song 4. Quit Enter
selection: 3 Playing song: The Sound of Silence by Simon and
Garfunkel Options: 1. Add a new song to the end of the playlist 2.
Insert a new song to the beginning of the playlist 3. Play the next
song 4. Quit Enter selection: 3 Playing song: Let it Be by the
Beatles Options: 1. Add a new song to the end of the playlist 2.
Insert a new song to the beginning of the playlist 3. Play the next
song 4. Quit Enter selection: 3 The playlist is currently empty.
Options: 1. Add a new song to the end of the playlist 2. Insert a
new song to the beginning of the playlist 3. Play the next song 4.
Quit Enter selection: 4 Goodbye
TESTING YOUR PLAYLIST PROGRAM
To help keep your focus squarely on the data structure
involved, and not on matching a particular testBed output, an
automated grading script is not provided. Instead, test your own
code by adding different songs to the beginning and end of the
playlist, and playing them. Ensuring that everything works as you
would expect.
In: Computer Science
-----------------------------------------------------------------------------------------------
Create a class called MathOperations that a teacher might use to represent the basic type of mathematical operations that may be performed. The class should include the following:
Three double private variables as instance variables, number1, number2, and result.
Your class should have a default constructor that initializes the three instance variables to zero.
Your class should also have a constructor that initializes the two instance variables (number1 and number2) to the value entered by the user from keyboard.
Also provide an accessor (getter) and mutator (setter) method for each instance variable except the result, that only has an accessor method.
In addition, provide 4 methods called addNumbers(), subNumbers(), divNumbers() and mulNumbers() that calculate the relevant addition, subtraction... operations on the two numbers entered by the user and stores it in the result variable.
Create a main method and within this method create 2 objects (obj1, obj2) of the MathsOperations class that sets/initializes the two instance variables (number1 and number2) by values entered by the user from the keyboard (Hint: Use Scanner class object).
7. Call/invoke each method on these 2 objects and print the result of each operation performed (using the result getter method).
8. Note: Please make sure to check when performing a division operation that the denominator is not zero. If the denominator is zero then simply set the result to zero. (Hint: Use condition statements)
In: Computer Science
QUESTION 2
write a c++ program
Assume that you own a construction company that builds different types of buildings. The goal is to write a program that is potentially useful for your company.
In: Computer Science
The NoSQL movement continues to grow to meet the Big Data storage needs of companies such as Amazon.com, Facebook, and Google. What are the unique security issues associated with these non-relational, structured storage DBMSs? Using our online Library system, summarize the finding of a reputable article’s information regarding the unique security issues with NoSQL databases.
In: Computer Science
use android studio or MIT inventor
Create a Presidents Quiz App for your project with the following requirements: You must have images Buttons Label Conditional Statement Homepage with instructions Sound (music, buzzer, etc.) - Ensure you are using the correct layout: Gravity(Android Studio), Horizontal or Vertical Arrangement (MIT). - 40POINTS Points System (indicating how many answers they got wrong/correct). 20POINT 1-2 questions per President (45+ questions)
In: Computer Science
Java Program
Suppose a student was taking 5 different courses last semester. Write a program that
(a) asks the student to input his/her name, student ID, marks for these 5 courses,
(b) calculate the average,
(c) determine the letter grade of each course.
(d) record the number of courses whose final letter grade is A+, A, A-, .... , F+, F, F-.
(e) Output the following information in a nice format: student name, student ID, listing of marks, the average, letter grade for each course, and the number of courses in each letter grade category.
I dont know how to do part ( d )
here is my code:
import java.util.Scanner;
public class Question_2 {
public String Grade(int mark) {
String GradeLetter = "";
if (mark >= 93 && mark <= 100)
GradeLetter = "A+";
if (mark >= 86 && mark < 93)
GradeLetter = "A";
if (mark >= 80 && mark < 86)
GradeLetter = "A-";
if (mark >= 77 && mark < 80)
GradeLetter = "B+";
if (mark >= 73 && mark < 77)
GradeLetter = "B";
if (mark >= 70 && mark < 73)
GradeLetter = "B-";
if (mark >= 67 && mark < 70)
GradeLetter = "C+";
if (mark >= 63 && mark < 67)
GradeLetter = "C";
if (mark >= 60 && mark < 63)
GradeLetter = "C-";
if (mark >= 57 && mark < 60)
GradeLetter = "D+";
if (mark >= 53 && mark < 57)
GradeLetter = "D";
if (mark >= 50 && mark < 53)
GradeLetter = "D-";
if (mark >= 35 && mark < 50)
GradeLetter = "F";
if (mark >= 0 && mark < 35)
GradeLetter = "F-";
return GradeLetter;
}
public static void main(String[] args) {
Question_2 q2 = new Question_2();
// declare variables
String name;// student name
int studentID;// student ID
int mark1, mark2, mark3, mark4, mark5;// student marks in each 5 courses
// asks the student to input his/her name
System.out.println("Input your first name: ");
Scanner input = new Scanner(System.in);
name = input.nextLine();
// asks the student to input student ID
System.out.println("Input your StudentID (integer in 5 digits),ex:000000 :");
studentID = input.nextInt();
// asks the student to input marks of 5 different courses last semester
System.out.println("Input your courses grade (0-100)integer number ");
System.out.println("Your course1's grade: ");
mark1 = input.nextInt();
System.out.println("Your course2's grade: ");
mark2 = input.nextInt();
System.out.println("Your course3's grade: ");
mark3 = input.nextInt();
System.out.println("Your course4's grade: ");
mark4 = input.nextInt();
System.out.println("Your course5's grade: ");
mark5 = input.nextInt();
// Calculate the average of 5 different courses last semester
double average = (mark1 + mark2 + mark3 + mark4 + mark5) / 5.0;
/*
* Output the following information in a nice format: student name,
* student ID, listing of marks, the average, letter grade for each
* course, and the number of courses in each letter grade category.
*/
System.out.println("**********************************************");
System.out.println("Student Name: " + name);
System.out.println("Student ID : " + studentID);
System.out.println(name + " grade in " + "Course1: " + mark1 + " " + q2.Grade(mark1));
System.out.println(name + " grade in " + "Course2: " + mark2 + " " + q2.Grade(mark2));
System.out.println(name + " grade in " + "Course3: " + mark3 + " " + q2.Grade(mark3));
System.out.println(name + " grade in " + "Course4: " + mark4 + " " + q2.Grade(mark4));
System.out.println(name + " grade in " + "Course5: " + mark5 + " " + q2.Grade(mark5));
System.out.println(name + " avaerage grade is: " + average);
System.out.println("**********************************************");
}
}
In: Computer Science
In C#. Explain the technique of fusing loop.Give example.
In: Computer Science