Questions
Java Programming Write a program that displays the following pattern *                         *       &nbsp

Java Programming

Write a program that displays the following pattern

*

                        *          *          *

*          *          *          *          *         

*          *          *          *          *          *          *

            *          *          *          *          *

                        *          *          *

                                    *

Printing Pattern A

*

**

***

****

*****

******

*******

Printing Pattern B

*******

******

*****

****

***

**

*

Printing Pattern C

*

**

***

****

*****

******

*******

In: Computer Science

Workshop: SQL Simple Retrieval For this workshop, you are to submit the SQL statements. Do not...

Workshop: SQL Simple Retrieval For this workshop, you are to submit the SQL statements. Do not submit the output produced by running the query. However, you may wish to examine the output to ensure the correctness of the query. When writing a query, do not rely exclusively on the current content of the database. Remember that when working with a real-world company’s database there can be far too many rows to allow you to visually examine the content of a table and validate your query. The following exercises all pertain to the FACULTY table. This table has the following columns: FNO, FNAME, FADDR, FHIRE_DATE, FNUM_DEP, FSALARY, and FDEPT. The table is owned by the user STUDENT.

1. Display the entire FACULTY table.

2. Display all information about any employee whose yearly salary is less than $40000.

3. Display all information about any employee who is employed by the Computer and Information Systems (CIS) Department.

4. Display the department, faculty number, and name of all faculty members.

5. Display the name and date of hire for any faculty member whose department alphabetically precedes THEO.

6. Display the departments to which faculty are assigned. Do not show duplicate values.

7. Display the name and salary of any employee earning less than $36000. Present the result set such that the highest paid employee is listed first, the second highest is listed next, and so on - that is, show the result with salaries in descending sequence.

8. Display the department, employee name, and salary for every employee. The output should be presented such that rows are arranged by salary within department. (Employees assigned to the same department will appear next to each other, but these rows will be sorted by salary.)

In: Computer Science

1. Write a program that includes a function search() that finds the index of the first...

1. Write a program that includes a function search() that finds the index of the first

element of an input array that contains the value specified. n is the size of the array. If

no element of the array contains the value, then the function should return -1. Name your

program .C The program takes an int array, the number of elements in the array,

and the value that it searches for. The main function takes input, calls the

search()function, and displays the output.

int search(int a[], int n, int value);

Example input/output #1:

Enter the length of the array: 4

Enter the elements of the array: 8 2 3 9

Enter the value for searching: 3

Output: 2

Example input/output #2:

Enter the length of the array: 6

Enter the elements of the array: 4 7 1 0 3 9

Enter the value for searching: 5

Output: -1

2. Modify the part 1 program so that it deletes all instances of the value from the array. As

part of the solution, write and call the function delete() with the following

prototype. n is the size of the array. The function returns the new size of the array after

deletion (The array after deletion will be the same size as before but the actual elements

are the elements from index 0 to new_size-1). In writing function delete(), you may

include calls to function search(). The main function takes input, calls the

delete()function, and displays the output. Name your program .C

int delete(int a[], int n, int value);

Example input/output #1:

Enter the length of the array: 6

Enter the elements of the array: 4 3 1 0 3 9

Enter the value for deleting: 3

Output array:

4 1 0 9

In: Computer Science

Step 1) Following the steps from prior weeks, add a new page to your website. Save...

Step 1) Following the steps from prior weeks, add a new page to your website. Save this new page as AboutUs.html. Make sure that the name of the page does not have a space (see the screenshot below of the Save dialogue box).

Step 2) Add the <body> tag, navigation, and <header> tag. The header <h1> text should say “About Us”.

Hint: Refer to Week Three, Steps 3, 4, and 5 for a refresher on how to add these elements.

Step 3) Add a link to the external CSS page.

Hint: Refer to Week Three, Step 8 for a refresher on how to add the link to the MyStyle.css page.

Step 4) Save your page and open it in a web browser, such as IE or Chrome. Your page should render like the image below with the header and the navigation on the top right of the page.

Step 5) Add a <div> tag between the closing </header> and closing </body> tags. To avoid confusion with <div> tags that you will add later, name this tag “div1”.

<div name="div1">

</div>

Step 6) Add a new file folder named media to the folder where you’ve chosen to save your Week Five files (the screenshot below shows your file structure with the media folder in the same place as your HTML and CSS files).

Step 7) Copy the file named Swiss_Mountain_House.mp4 to the “media” folder.

Note: It’s important that you have the legal right to use any and all media files you add to web pages; you automatically own all rights to media files you created yourself, most other files you must obtain permission from the owner of the file. Some copyright owners grant free use of their work just for asking. Websites that offer free media files will state on their site that the files are royalty free. Never use someone else’s work without being sure you have the right to do so. In this case, your instructor has ensured you have the right to use these files.

Step 8) Within the opening <div> and closing <div> tags for “div1”, add the following code to add a video clip to your AboutUs.html page:

<video width="400px" controls>

   <source src="media/Swiss_Mountain_House.mp4" type="video/mp4">

   Use a browser (such as IE or Chrome) that supports the HTML5 video tag for mp4 files.

</video>

Note: The source “src” tag for the path is pointing to the media folder. The line under the <source> tag is verbiage that the user may see if the browser is not compatible with the HTML5 video tag, or if the file is missing. All browsers behave differently, but it is a good practice to provide the alternate text.

Step 9) Add the following HTML comment on the line above the beginning <video> tag. Note the syntax that delineates the start and stop of the HTML comment. The HTML interpreter will ignore everything between the opening and closing comment tags so you only see this comment when you look at the source. Notice that the HTML comment syntax is different from the JavaScript® comment syntax.

<!-- Royalty-free video loops are from https://www.freeloops.tv/ -->

Step 10) Save and refresh the browser. Your page should render like the image below with an embedded video file below the header.

Step 11) Click the play arrow to test the 5-second video.

Note: There is no audio with this video.

Step 12) Copy the files named Cow-SoundBible.mp3 and Cow-SoundBible.wav to the “media” folder.

Step 13) Add a second <div> tag (named “div2”) after the closing </div> tag for “div1”, but before the closing </body> tag. Insert the <article> and <audio> element code below. Note that the source “src” tag for the path is pointing to the media folder and there is also a comment above the opening <audio> tag.

        <div name="div2">

<article >

Our cheese products come from the finest farms in Switzerland. Click the audio play button below to hear our happy cows!

</article>

<!-- Royalty-free sound clips are from http://soundbible.com/ -->

<audio controls >

   <source src="media/Cow-SoundBible.mp3" type="audio/mpeg">

   <source src="media/Cow-SoundBible.wav" type="audio/wav">

   <source src="media/Cow-SoundBible.ogg" type="audio/ogg">

   Your browser does not support the audio tag.

</audio>

        </div>

Step 14) Save and refresh the browser. The page will render like the image below with text and the embedded sound file below the video. Press the audio play arrow to test the audio.

  

Note:In Step 14, the line under the <source> tag is verbiage that users may see if their browsers are not compatible with the HTML5 audio tag, or if the audio files are missing. To simulate this situation, comment out the two lines for the MP3 and WAV files. When your interpreter cannot see the two commented-out lines, it will only read the file for the OGG file. Since that file is missing, your browser will either show the alternate text, or disable the audio control. All browsers behave differently, but providing these options allows different browsers to handle the situation gracefully. Without these options, a browser might display a broken link to a sound file with no explanation, which would confuse your users and give them the impression that your site is poorly constructed. Remember that in HTML the beginning comment tag is <!-- and the closing comment tag is -->. If you tested the missing file scenario above, be sure to uncomment the lines that point to the MP3 and WAV files.

Step 15) To float “div1” and “div2” side-by-side, use the "myColumns" CSS class from Week One to both <div> tags. Save your file after you are finished. The modified opening <div> tags will look like this:

<div name="div1" class="myColumns">

<div name="div2" class="myColumns">

Step 16) Open the MyStyle.css page in NotePad++. Add the following code to the end of the existing code, right after the closing curly brace } for the myColumns block, as follows:

.aboutUsMedia {

            width: 250px;

}

Step 17) Back in the AboutUs.html page, modify the opening <video>, opening <article> tag, and opening <audio> tags.

Note: The “aboutUsMedia” class will replace the “width” attribute for the <video> tag.

  1. Remove the width="400px" statement from the opening <video> tag and replace it with the class="aboutUsMedia" statement. The code will look like the example line below:

<video class="aboutUsMedia" controls>

  1. Add the class="aboutUsMedia" statement to the opening <article> and opening <audio> tags, as follows:

<article class="aboutUsMedia">

<audio class="aboutUsMedia" controls >

Step 18) Save and refresh the browser. The <video> tag, <article> tag, and <audio> tag are all resized to a width of 250px, and the two <div> tags are now floating side-by-side as shown in the image below.

Step 19) Add the following <footer> code between the closing </body> tag and the closing </html> tag:

<footer>

Click

<a href="https://www.nationalgrocers.org/" target="_blank">here</a>

to learn more about the National Grocers Association.

</footer>

Step 20) To push the <footer> to the bottom of the page, and to stop the floating of the footer to the right, add the following to the end of your MyStyle.css page.

footer {

            clear:both; /* this clears the float */

            display: block;

            position: absolute;

            bottom: 0;

            left: 0;

            right: 0;

background-color: lightgray;

text-align: center;

}

Step 21) Save your file and refresh it in the browser window. Your page should render like the image below with a formatted footer at the bottom of the page that includes a link. To test the external link, click the “here” hyperlink in the footer at the bottom of the page. The external page will open in a new window.

Note: Be sure to save all the files, as you modified the AboutUs.html and MyStyle.css files in the prior steps.

In: Computer Science

Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.

Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.

In: Computer Science

4.2 Lab: new and delete new is the operator used to dynamically allocate memory while the...

4.2 Lab: new and delete

new is the operator used to dynamically allocate memory while the program is running

delete is the operator used to release memory when it is no longer needed, so it could be used next time new is used

This lab gives you an example of using new and delete with an array of structures.

Your tasks are listed below:

  • review the existing code
  • finish writing the copyList()function

// Lab: new and delete
#include <iostream>
#include <string>
using namespace std;

struct Stu{
string name;
double gpa;
};

Stu *copyList(Stu list[], int n);
void printList(Stu *list, int n, string desc);

int main() {

Stu list[10] = {{"Tom", 3.5}, {"Bob", 2.9}, {"Ann", 3.2}, {"Dan", 3.1}, {"Zoe", 2.9}};
Stu *backup;
int n = 5;

printList(list, n, "Original");
backup = copyList(list, 5);
printList(list, n, "Backup");

// Release memory
delete [] backup;

return 0;
}
// This function dynamically allocates an array of n STU structures,
// copies data from list to the new array, one element at a time,
// and returns a pointer to the new array
Stu *copyList(Stu list[], int n)
{
Stu *backup;

/* write your code here */

return backup;
}

// This functions displays an array of structures
// Note: it doesn't matter if the array is
// statically allocated or dynamically allocated
void printList(Stu *anyList, int n, string desc)
{
cout << endl << desc << endl;
for (int i = 0; i < n; i++)
{
cout << anyList[i].name << " " << anyList[i].gpa << endl;
}
}

// please do not use any recursive functions or anything, this simply testing pointers

In: Computer Science

Write a program that takes an infix expression as input and produces a postfix expression. The...

Write a program that takes an infix expression as input and produces a postfix expression. The infix and postfix expressions are in the form of vectors of strings. We will test with a main method that takes a file name as input from the command line. We will test your implementation using printPostFix() method.   There are sample input and output files in this folder. You may edit the header file.

Example 1

infix expression = apple + banana * cat

vector inFixTokens = {"apple", "+", "banana", "*", "cat"}

postfix expression = apple banana cat * +

vector postFixTokens = {"apple", "banana", "cat", "*", "+"}

Example 2

infix expression = (apple + banana) * cat ^ dog + egg

vector inFixTokens = {"(", "apple", "+", "banana", ")" , "*", "cat", "^", "dog", "+", "egg"}

postfix expression = apple banana + cat dog ^ * egg +

vector postFixTokens = {"apple", "banana", "+", "cat", "dog", "^", "*", "egg", "+"}

Use the algorithm given in the lecture slides on stacks.

Use the following header file to create a PostFixTokens class.

PostFixTokens.h

We will test your implementation by creating instances of PostFixTokens and calling createPostFix and printPostFix. *Do not change the method signatures because we will use them to test your implementation.*

Operators: ^, *, /, +, -

Precedence: ^ > * / > + -

You must account for parentheses ), (

Only binary operators. No unary operators. Minus sign (-) is not used for negation, only as a binary operator.

If the tokens of inFixTokens are an invalid expression, then any call to getPostFixTokens, printPostFix, or createPostFix should throw a std::invalid_argument exception.

Header Given:

#ifndef PostFixTokens_h
#define PostFixTokens_h
#include 
#include 
#include 

using namespace std;

class PostFixTokens {
public:
PostFixTokens();
PostFixTokens(vector inFix);
~PostFixTokens();

    vector getPostFixTokens();
    vector getInFixTokens();
    void setInFixTokens(vector inFix);
    void printPostFix();
    void printInFix();
    void createPostFix();


private:
vector inFixTokens;
vector postFixTokens;
    
};


#endif /* PostFixTokens_h */

Tester File given:

#include
#include
#include
#include
#include "PostFixTokens.h"

class ostream_suppressor {
std::ostream &out;
std::ostringstream buffer;
std::streambuf *old_buffer;
public:
ostream_suppressor(std::ostream &out) : out(out) {
old_buffer = out.rdbuf(buffer.rdbuf());
}

~ostream_suppressor() {
out.rdbuf(old_buffer);
}
};

static const std::list token_types = {
std::regex("^(-?\\d+)"), // numbers
std::regex("^[\\(\\)\\+\\-\\*\\/%\\^]"), // operators
std::regex("^[[:alpha:]]([[:alnum:]_-]*)") // variables
};

std::vector tokenize(const std::string infixExp) {
auto tokens = std::vector{};
auto matches = std::smatch{};

auto it = begin(infixExp), endIt = end(infixExp);
while(it != endIt) {
for(const auto &token_type: token_types) {
if(std::regex_search(it, endIt, matches, token_type)) {
tokens.push_back(matches[0]);
// move the iterator forward to the end of the found token
it += matches[0].length()-1;
break;
}
}
++it;
}

return tokens;
}

void printTokens(std::vector &tokens) {
if(tokens.size() == 0) return;

std::cout << tokens[0];
std::for_each(begin(tokens)+1, end(tokens), [](const auto &token) {
std::cout << " " << token;
});
std::cout << std::endl;
}

int main() {
std::string infixExp;

while(std::getline(std::cin, infixExp)) {
try {
auto inFixTokens = tokenize(infixExp);

std::vector postFixTokens;
{
ostream_suppressor supressor(std::cout);
PostFixTokens tokens(inFixTokens);
tokens.createPostFix();
postFixTokens = tokens.getPostFixTokens();
}

printTokens(postFixTokens);
} catch (std::invalid_argument &e) {
std::cout << "Invalid infix expression\n";
} catch (std::exception &e) {
std::cout << "Unexpected exception thrown with message " << e.what() << "\n";
}
}
}

In: Computer Science

you are required to use only the functional features of Scheme; functions with an exclamation point...

you are required to use only the functional features of Scheme; functions with an exclamation point in their names (e.g., set!) and input/output mechanisms other than load and the regular read-eval-print loop are not allowed. (You may find imperative features useful for debugging. That’s ok, but get them out of your code before you hand anything in.)

Write a function sublist that takes two lists as arguments, and returns true if the first list appears as a contiguous sublist somewhere within the second list, and false otherwise.

> (sublist ’(c d e) ’(a b c d e f g))

#t

> (sublist ’(a c e) ’(a b c d e f g))

#f

using the programming language scheme

In: Computer Science

Do the fllowing: • Start up your web browser, and make sure your browser's cache is...

Do the fllowing:
• Start up your web browser, and make sure your browser's cache is cleared, as
discussed above.
• Start up the Wireshark packet sniffer
• Enter the fllowing URL into your browser

http://gaia.cs.umass.edu/wireshark-labs/HTTP-wireshark-file4.html
Your browser should display a short HTML fle with two images. These two
images are refrenced in the base HTML fle. That is, the images themselves are
not contained in the HTML; instead the URLs fr the images are contained in the
downloaded HTML fle. As discussed in the textbook, your browser will have to
retrieve these logos fom the indicated web sites. Our publisher's logo is
retrieved fom the gaia.cs.umass.edu web site. The image of the cover fr our 5
th
edition (one of our fvorite covers) is stored at the caite.cs.umass.edu server.
(These are two different web servers inside cs.umass.edu).
• Stop Wireshark packet capture, and enter "http" in the display-flter-specifcation
window, so that only captured HTTP messages will be displayed.

(Note: If you are unable to run Wireshark on a live network connection, you can
use the http-ethereal-trace-4 packet trace to answer the questions below; see
fotnote 1. This trace fle was gathered while perfrming the steps above on one
of the author's computers.)
Answer the fllowing questions:
16. How many HTTP GET request messages did your browser send? To which
Internet addresses were these GET requests sent?
17. Can you tell whether your browser downloaded the two images serially, or
whether they were downloaded fom the two web sites in parallel? Explain.

In: Computer Science

Write a Python program that extracts 1000 unique links from Twitter using Tweepy. How can I...

Write a Python program that extracts 1000 unique links from Twitter using Tweepy. How can I filter out all links with Twitter domains and shortened links?

In: Computer Science

Suppose there are 4 routers in sequence between Host A and Host B, all of which...

Suppose there are 4 routers in sequence between Host A and Host B, all of which use store-and-forward routing. What is the total end-to-end delay for a packet originating from Host A with destination Host B, under the following conditions.


◘ Each of the link transmission rates are 9.4 Mbps
◘ The total distance from Host A to Host B along its path of transmission is123.4 km
◘ The speed of propagation through the transmission medium is is 2.5 x 10 m/s
◘ The packet size is 2 KiB


Remember that you must also uplink from Host A to the first router. Give answer in milliseconds, rounded to 1 decimal place, without units (e.g. for 0.12345 seconds you would enter "123.5" without the quotes).

The answer is 9.2

Why is this the correct answer?

In: Computer Science

Please use original C++ code for this. This is for visual studio. Program 5: Shipping Calculator...

Please use original C++ code for this. This is for visual studio.

Program 5: Shipping Calculator

The Speedy Shipping Company will ship packages based on how much they weigh and how far they are being sent. They will only ship small packages up to 10 pounds. You have been tasked with writing a program that will help Speedy Shipping determine how much to charge per delivery.

The charges are based on each 500 miles shipped. Shipping charges are not pro-rated; i.e., 600 miles is the same charge as 900 miles; i.e., 600 miles is counted as 2 segments of 500 miles.

Here is the table they gave you:

Package Weight                                           Rate per 500 miles shipped

2 pounds or less $1.50

More than 2 but not more than 6                              $3.70

More than 6 but not more than 10                            $5.35

Test Case 1:

Input Data:

Weight:            1.5 pounds

Miles:              200 miles                                (This is one 500-mile segment.)

Expected result:

To ship a 1.5 pound package 200 miles, your shipping charge is $1.50.

Test Case 2:

Input Data:

Weight:            5.6 pounds

Miles:              1200 miles                              (This is three 500-mile segments.)

Expected result:

To ship a 5.6 pound package 1200 miles, your shipping charge is $11.10.

Test Case 3:

Weight:            1.0 pounds

Miles:              2500 miles                               (This is five 500-mile segments.)

Expected result:

To ship a 1.0 pound package 2500 miles, your shipping charge is $7.50.

Test Case 4:

Weight:            8.5 pounds

Miles:              12345 miles                            (This is twenty-five 500-mile segments.)

Expected result:

To ship a 8.5 pound package 12345 miles, your shipping charge is $133.75.

Test Case 5:

Weight:            12.8 pounds

Miles:              345 miles  

Expected result:

Sorry, we only ship packages of 10 pounds or less.

Hints: This program does not need any loops. The program will calculate one shipping charge and stop. Your test cases should test the various possibilities, and the limits of the program.

BIG Helpful Hint: You can use integer division. For example: 1200 / 500 = 2

Send email if you are stuck, or if there is something in this assignment that you are confused about.

Rubric:

Well-formatted code (indentation, use of whitespace, comments)

10%

Good variable names (proper case, meaningful identifiers)

10%

Good prompts (accurate, easy-to-use user interface)

10%

Calculations are correct

40%

Well-formatted output

10%

Screenshots showing your program running on your computer

20%

In: Computer Science

Write a python script to calculate the average length of the game shortest game , longest...

Write a python script to calculate the average length of the game shortest game , longest game and the overall average length of a snake and ladder game

The game length is the number of throws of the die. We are asked to write a python script which calculate that together with the average

In: Computer Science

Any given viewpoint may contain concepts from one or more layers of the ArchiMate language. If...

Any given viewpoint may contain concepts from one or more layers of the ArchiMate language. If this content is regarded as the scope of a viewpoint, discuss a reasonable categorization scheme for a basic set of viewpoints that addresses stakeholders’ concerns. Give an example of a viewpoint per category in terms of a Name for the viewpoint, its perspective and it scope. (20)

In: Computer Science

MATLAB Suppose that $2000.00 is left to sit in a bank account that initially pays 7%...

MATLAB

Suppose that $2000.00 is left to sit in a bank account that initially pays 7% interest per year, compounded annually. However, if the balance in the account exceeds $10000.00, the interest rate increases to 9%. Write a code that does the calculation of account balance after every year, and stores it in a vector balaceV.

What will be the value of the vector after 30 years of saving? Plot the resulting vector versus time (years), using any style you like (line/points/bars). Make sure that the vector's first value of balance (meaning the initial deposit at time=0) is also included, so the resulting vector for 30 years should contain 31 elements. The x-axis should have values from 0 to 30.

In: Computer Science