Questions
Question? Identify the relationships of Player and Player fields including PKs, CKs, and FDs. While using...

Question?

Identify the relationships of Player and Player fields including PKs, CKs, and FDs. While using the entities and fields found in Player, create a DBDL example of tables, fields, and key fields that are in third normal form.

Instructions: Convert this table to an equivalent collection of tables, fields, and keys that are in the third normal form. Represent your exercise answers in DBDL design from the database normalization phases.

The player contains information about players and their teams.

Player has attributes PlayerId, First, Last, Gender, TeamId, TeamName, TeamCity where PlayerId is the only CK and the FDs are:

PlayerId → First

PlayerId → Last

PlayerId →Gender

PlayerId → TeamId

PlayerId → TeamName

PlayerId → TeamCity

TeamId → TeamName

TeamId → TeamCity

Figure 1: Player – Sample Data

PlayerID First Last Gender TeamID TeamName TeamCity
1 Jim Jones M 1 Flyers Winnipeg
2 Betty Smith F 5 OilKings Calgary
3 Jim Smith M 10 Oilers Edmonton
4 Lee Mann M 1 Flyers Winnipeg
5 Samantha McDonald F 5 OilKings Calgary
6 Jimmy Jasper M 99 OilKings Winnipeg

In: Computer Science

A local client needs to take his static web page for ordering organic vegetables and build...

A local client needs to take his static web page for ordering organic vegetables and build a dynamic page. He doesn't have much money to spend, so we are going to write orders to a flat file. He is also going to need a page that he can go to that will display his orders.

He has already met with Sharron, so we've got a specification already assembled. Here are the details:

The customer will go to a form page where they can enter an order for vegetables. The file will be called orderVegetables.php. Here are products a customer can order:

  • 5 lb Potatoes, $6.00 each
  • 3 lb Carrots, $3.75 each
  • 1 Cauliflower, $4.00 each

The customer should be able choose a quantity of items beside any of the vegetable options. Only allow orders where there is at least one thing ordered. Also, if the total price is over $50 then they qualify for free delivery, otherwise delivery cost is $5.00. (You can apply the delivery fee after tax, or before). Be sure to also capture the customers name, email and phone number on the form so the client can contact them to setup delivery. Make sure each order has the date and time of the order as well. Don't forget to use \r\n for a new line at the end of each record.

When the user clicks 'submit,' a POST request is made to processVeggies.php where the order is written to the file veggie-orders.txt. The text file should be simply a storage place in lieu of using a proper database. Some would call it a 'flat-file' storage system. Make sure to lock the file before appending, and to unlock it afterwards. Display a thank you message to the client and print their order details to the screen. Let them know that they will be contacted within the next business day.

Of course the client would like a page to view all the orders. This file will be called viewOrders.php. The client would like a link on this page to reset the orders (reset the veggie-orders.txt file) called Reset Orders. This link will call a file resetOrders.php. The client will typically print off a days worth of orders and then reset the form for the next day. Don't worry about locking the file on your reset page.

Good luck! We need this prototype soon!

- Ima Plant

Senior Consultant,
Acme International Inc.

====

The order form also needs to capture customer name, phone number, and email.

What to expects

1. The input page (named orderVegetables.php) needs to have the following fields:

a. Select drop-down fields should be used to allow users to choose a quantity for each item. Limit the options to 0-30.

b.We also need fields for name, email, and phone number.

2. Look and Feel: Use bootstrap or not, your choice. The header of each page should contain a masthead/header image that would befit an upscale veggie shop. Please use GIMP, MS PAINT or some other editor to create this header image for the top of your page. Or better yet, set your header text using <h1> or <h2> and set the image you create as a background-image in your CSS. As well, all formatting should be done using CSS in an external stylesheet. Please use a div with an id of 'container' to hold your content. Ensure that this simple theme is present for ALL of your pages!

3. The processing page (named processVeggies.php) needs to include the following:

a. Order details gathered from input form.

b. Whether or not delivery is free - display a message to the user one way or the other (include dollar sign and two decimal places - that is, format for currency)

c. Assume a provincial tax rate of 15%

d. Calculate and display the details of their order, net amount before tax, tax amount, delivery amount, and total amount.

e. Include the time, date, and year (for Atlantic Canada) that the order was processed.

f. Ensure that there is some type of validation on the processing page. If someone tried to run it without accessing the form page first, it should give the user a link back to the order page.

4. The processing page (processVeggies.php) should also write this order to a file.

a .Ensure file is accessible to your script, but hidden from public browsing. Please note that veggie-orders.txt MUST be stored one directory behind your publishing directory. "$DOCUMENT_ROOT/../veggie-orders.txt" would be an example.

b. Orders file should be delimited by a "\t" or some other delimiter. " \r\n" at the end of each line.

5. The viewOrders.php page should open the file for reading only and display, in html, all of the pending orders for the day. The look and feel of this page should follow the store's theme. Though this page would be used only by administrators of the site, we will not lock it down. For now, assume it will be live for all to view. Please create a table to hold all of the pending orders. Each line of the order file could be a table row. You can keep this simple, no need to use explode() or list() if you don't want to. As well on this page, create a hyperlink to resetOrders.php (see below). If there are no pending orders, ensure there is a message to the user stating the fact.

6. Create another page called resetOrders.php. This page should reset the orders file (delete the file contents), give the user confirmation that the file has been cleared and give them a link/instructions on what to do next.

7. All pages should be accessible via links. So there should be some sort of menu.  I DON'T need a link to process orders as that would be silly. Remember menus should go at the top of your pages.

8.Comments, Code Formatting, Submission Packaging (variable naming, page naming).

In: Computer Science

Given an integer named area which represents the area of a rectangle, write a function minPerimeter...

Given an integer named area which represents the area of a rectangle, write a function minPerimeter that calculates the minimum possible perimeter of the given rectangle, and prints the perimeter and the side lengths needed to achieve that minimum. The length of the sides of the rectangle are integer numbers. For example, given the integer area = 30, possible perimeters and side-lengths are: (1, 30), with a perimeter of 62 (2, 15), with a perimeter of 34 (3, 10), with a perimeter of 26 (5, 6), with a perimeter of 22 Thus, your function should print only the last line, since that is the minimum perimeter. Some example outputs: >>>minPerimeter(30) 22 where rectangle sides are 5 and 6. >>>minPerimeter(101) 204 where rectangle sides are 1 and 101. >>>minPerimeter(4564320) 8552 where rectangle sides are 2056 and 2220.

In: Computer Science

PYTHON! Exercise 3 - Total Line length Write a python function that will return the total...

PYTHON!

Exercise 3 - Total Line length

Write a python function that will return the total length of line that passes through any number of provided points ( (x,y) ). The points should be passed as individual tuples or lists. The function should also have a parameter (True or False) to indicate whether the line should start from the origin, and that parameter should default to False. If True, the returned value should include the distance from the origin to the first point, otherwise start adding distances from the first point. So a function call could look something like this:

dist = lineLength((1,2), (2,3), (7,4), start=False)

Demonstrate it in your main program by calculating the length of line going through the following 5 points (with and without the origin option set to True):

(1,1), (-2,4), (-3,-2), (2,-1), (1,1)

PreviousNext

In: Computer Science

Task 1. Consider the following scenarios An order processing application for a pet supplies store. The...

Task 1. Consider the following scenarios

  1. An order processing application for a pet supplies store. The customers should be able to place orders online and for every order they must receive an order confirmation vie e-mail and upon shipping they must receive a shipping notice via e-mail.
  2. A publicly traded retailer with retail outlets and online shopping and shipping options
  3. A small, private law firm having a small website with forms for potential clients to complete; including name, address, contact number, and reason for scheduling an appointment
  4. A real estate Appraisal Company that provides online appraisals for a publicly traded financial institution’s residential-loan applicants which sends all applicant information to the appraisal company electronically
  5. A Web hosting company that provides leased servers for Web sites of client’s ranging from small firms to large online retailers
  6. A city government that allows people with parking tickets to pay the fines online using a credit card or online check

Last week we discussed in the class, the threats posed by each of the above scenarios and explain what its effect may be if a web application is compromised. One of the software strategies to cover the emergent security threat to an application is to build abuse cases. The result I expect is a report which integrates the software development lifecycle with security in every step of it for the abuse case described for any one of the scenarios mentioned above. You can also attempt the exercise for any scenario which interests you . (5 points)

In: Computer Science

Please use the search engine (Such as google and baidu) to visit four different websites about...

Please use the search engine (Such as google and baidu) to visit four different websites about hotels or scenic spots, describe the features of these sites and multimedia elements.
What kind of multimedia presentation does the site take? Video? Flash? 3D animation or only images?
Please use the search engine (Such as google and baidu) to visit four different websites about hotels or scenic spots, describe the features of these sites and multimedia elements.
What kind of multimedia presentation does the site take? Video? Flash? 3D animation or only images?
Analyze their advantages and disadvantages.
Discussing whether the multimedia application is appropriate, and how to add some additional media content to improve this site. Give some advices.

In: Computer Science

In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h....

In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h. BST.h code below. CPP code also provided for reference, nothing to be changed on cpp code.

#include 
#include "BSTNode.h"
using namespace std;

#ifndef BST_H_
#define BST_H_

class BST {

public:

        BSTNode *root;
        int size;

        BST() {
                root = NULL;
                size = 0;
        }

        ~BST() {
                if (root != NULL)
                        deepClean(root);
        }

        BSTNode *search(int key) { // complete this method
        }

        BSTNode *insert(int val) { // complete this method
        }

        bool remove(int val) { // complete this method
        }

private:

        void removeLeaf(BSTNode *leaf) { // complete this method
        }

        void removeNodeWithOneChild(BSTNode *node) { // complete this method
        }

        static BSTNode *findMin(BSTNode *node) {
                if (NULL == node)
                        return NULL;
                while (node->left != NULL) {
                        node = node->left;
                }
                return node;
        }

        static BSTNode *findMax(BSTNode *node) {
                if (NULL == node)
                        return NULL;
                while (node->right != NULL) {
                        node = node->right;
                }
                return node;
        }

        void print(BSTNode *node) {
                if (NULL != node) {
                        node->toString();
                        cout << " ";
                        print(node->left);
                        print(node->right);
                }
        }

        static int getHeight(BSTNode *node) {
                if (node == NULL)
                        return 0;
                else
                        return 1 + max(getHeight(node->left), getHeight(node->right));
        }
    
    static void deepClean(BSTNode *node) {
        if (node->left != NULL)
            deepClean(node->left);
        if (node->right != NULL)
            deepClean(node->right);
        delete node;
    }

public:

        int getTreeHeight() {
                return getHeight(root);
        }

        void print() {
                print(root);
        }

        int getSize() {
                return size;
        }
};

#endif
testCorrectness.cpp
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "BST.h"
#include "Hashing.h"
using namespace std;

int arrayIns[] = { 11, 12, 15, 17, 12, 19, 4, 5, 11, 19, 20, 32, 77, 65, 66, 88,
                99, 10, 8, 19, 15, 66, 11, 19 };
const int numInsert = sizeof(arrayIns) / sizeof(int);

int searchArray[] = { 29, 3, 19, 27, 12, 34, 4, 5, 19, 20, 32, 45, 37, 25, 99,
                25, 8, 24, 12, 16 };
const int numSearch = sizeof(searchArray) / sizeof(int);

int deleteArray[] = { 16, 12, 15, 5, 17, 19, 4, 5, 19, 20, 32, 17, 19, 39, 99,
                10, 8, 19, 15, 21 };
const int numDelete = sizeof(deleteArray) / sizeof(int);

const int cleanUp[] = { 11, 77, 65, 66, 88 };
const int numCleanUp = sizeof(cleanUp) / sizeof(int);

const int TABLE_SIZE = 7;

void printArray(int *A, int len) {
        if (0 == len)
                cout << "[]";
        else {
                cout << "[";
                for (int i = 0; i < len - 1; i++) {
                        if (A[i] == INT_MAX)
                                cout << "infty, ";
                        else
                                cout << A[i] << ", ";
                }
                if (A[len - 1] == INT_MAX)
                        cout << "infty]";
                else
                        cout << A[len - 1] << "]";
                cout << endl;
        }
}

void printList(list &A) {
        if (0 == A.size())
                cout << "[]" << endl;
        else {
                list::iterator it;
                cout << "[";
                for (it = A.begin(); next(it) != A.end(); ++it)
                        cout << *it << ", ";
                cout << *it << "]";
                cout << endl;
        }
}

void printList(list *A) {
        if (0 == A->size())
                cout << "[]" << endl;
        else {
                list::iterator it;
                cout << "[";
                for (it = A->begin(); next(it) != A->end(); ++it)
                        cout << *it << ", ";
                cout << *it << "]";
                cout << endl;
        }
}

//HASHING -------------------------------------------
Hashing *testHashing() {
        cout << "****************** Test Hashing Correctness ******************"
                        << endl << endl;
        Hashing *hChain = new Hashing(TABLE_SIZE);

        cout << "Inserting the following numbers: ";
        printArray(arrayIns, numInsert);

        for (int i = 0; i < numInsert; i++) {
                hChain->insert(arrayIns[i]);
        }

        cout << endl << "*** Hash Table Structure (after insertion) ***" << endl;
        int size = 0;
        for (int i = 0; i < TABLE_SIZE; i++) {
                cout << "Slot " << i << ": ";
                printList(hChain->getList(i));
                size += hChain->getList(i)->size();
        }
        cout << endl << "Size of hash table: " << size << endl;

        cout << "\n*** Searching Hash Table ***" << endl;
        list foundList;
        list notFoundList;

        for (int i = 0; i < numSearch; i++) {
                int val = searchArray[i];
                bool found = hChain->search(val);
                if (found)
                        foundList.push_back(val);
                else
                        notFoundList.push_back(val);
        }
        cout << "Found: ";
        printList(foundList);
        cout << "Did not find: ";
        printList(notFoundList);
        cout << endl << "*** Deleting Hash Table ***" << endl;

        list deleteList;
        list deleteNotFoundList;
        for (int i = 0; i < numDelete; i++) {
                int val = deleteArray[i];
                bool deleted = hChain->remove(val);
                if (deleted)
                        deleteList.push_back(val);
                else
                        deleteNotFoundList.push_back(val);
        }
        cout << "Deleted: ";
        printList(deleteList);
        cout << "Did not find: ";
        printList(deleteNotFoundList);

        cout << endl << "*** Hash Table Structure (after deletion) ***" << endl;
        size = 0;
        for (int i = 0; i < TABLE_SIZE; i++) {
                cout << "Slot " << i << ": ";
                printList(hChain->getList(i));
                size += hChain->getList(i)->size();
        }
        cout << endl << "Size of hash table: " << size << endl;
        return hChain;
}

//BST
BST *testBST() {
        cout << "\n****************** Test BST Correctness ******************"
                        << endl << endl;

        BST *bst = new BST();
        cout << "Inserting the following numbers: ";
        printArray(arrayIns, numInsert);

        for (int i = 0; i < numInsert; i++) {
                bst->insert(arrayIns[i]);
        }

        cout << endl << "*** BST Structure (after insertion) ***" << endl;
        bst->print();
        cout << endl << endl << "Size of BST: " << bst->getSize() << endl;

        cout << "\n*** Searching BST ***" << endl;
        list foundList;
        list notFoundList;

        for (int i = 0; i < numSearch; i++) {
                int val = searchArray[i];
                if (bst->search(val) != NULL)
                        foundList.push_back(val);
                else
                        notFoundList.push_back(val);
        }
        cout << "Found: ";
        printList(foundList);
        cout << "Did not find: ";
        printList(notFoundList);
        cout << endl << "*** Deleting BST ***" << endl;

        list deleteList;
        list deleteNotFoundList;
        for (int i = 0; i < numDelete; i++) {
                int val = deleteArray[i];
                bool deleted = bst->remove(val);
                if (deleted)
                        deleteList.push_back(val);
                else
                        deleteNotFoundList.push_back(val);
        }
        cout << "Deleted: ";
        printList(deleteList);
        cout << "Did not find: ";
        printList(deleteNotFoundList);

        cout << endl << "*** BST Structure (after deletion) ***" << endl;
        bst->print();
        cout << endl << endl << "Size of BST: " << bst->getSize() << endl;
        return bst;
}

static void cleanTest(Hashing *hashing, BST *bst) {
        cout << "\n****************** Clean up ******************" << endl;
        for (int i = 0; i < numCleanUp; i++) {
                hashing->remove(cleanUp[i]);
                bst->remove(cleanUp[i]);
        }
        int size = 0;
        for (int i = 0; i < TABLE_SIZE; i++)
                size += hashing->getList(i)->size();

        cout << "\nSize of hash table: " << size << endl;
        cout << "Size of BST: " << bst->getSize();
        delete hashing;
        delete bst;
}

int main() {
        cleanTest(testHashing(), testBST());
        return 0;
}

BSTnode.h

#include <iostream>
using namespace std;

#ifndef BSTNODE_H_
#define BSTNODE_H_

class BSTNode {

public:

        int value;
        BSTNode *left, *right, *parent;

        BSTNode(int val) {
                // each node is inserted as a leaf
                value = val;
                left = NULL;
                right = NULL;
                parent = NULL;
        }

        void toString() {
                if (parent == NULL)
                        cout << "<" << value << ", null>";
                else
                        cout << "<" << value << ", " << parent->value << ">";
        }
};

#endif

In: Computer Science

Though threads simplify sharing within a process, context-switching between threads within a process is just as...

Though threads simplify sharing within a process, context-switching between threads within a process is just as expensive as context-switching between processes.

In: Computer Science

You have been asked to produce a spreadsheet analysis of the percentages of inpatients treated by...

You have been asked to produce a spreadsheet analysis of the percentages of inpatients treated by patient age. You need to communicate the percentage of patients who were ages 1 through 18, 19 through 35, 36 through 55, and 55 and older. The best type of graph to depict this would be:

Group of answer choices

Line graph

Stacked bar graph

Cluster bar graph

Pie chart

A and C

The use of a Database Management System would be best suited for:

Group of answer choices

Producing thematic maps

Creating a financial model

Creating pie charts

Performing “what-if” analysis

Managing the patient records of a physical therapy clinic

As manager you must create an analysis of staffing requirements for multiple departments. You will need to calculate the number of employees needed for each position using a series of complex formulas incorporating factors such as new patient admissions, the projected numbers of procedures to be performed, follow-up appointments, and several other variables. The best program for this effort would be:

Group of answer choices

Microsoft Access

Microsoft Word

ArcMap GIS

Microsoft Excel

None of the above

Which two of the following describe a relational database?

Group of answer choices

A relational database can consist of one single table containing all of the information.

Microsoft Access is not capable of creating a relational database, only flat file databases are allowed

Tables containing names must be sorted in alphabetical order

A relational structure is the often the best design for databases in which a single person-level record must be associated with multiple transaction records for the same individual

Each table in the relational join must contain a unique key field allowing the records to be joined to another table containing the same key field.

In comparison to Microsoft Excel, which one of the following statements with respect to Microsoft Access is true?

Group of answer choices

Access is more flexible since you can enter the data at the same time that you create the database structure.

Access allows you to quickly create complex formulas for specific cells.

Access database fields must be defined prior to any data being input into it.

Due to its capacity limitations, Access should not be used if there are over 1,000 records and the number is expected to grow over time.

Access allows data to be copied from one range to another.

In: Computer Science

Hello. Please answer the following two-part question in Scheme. Not Python, not any form of C,...

Hello. Please answer the following two-part question in Scheme. Not Python, not any form of C, but in the language Scheme. If you do not know Scheme, please do not answer the question. I've had to upload it multiple times now. Thank you.

2.1 Write a recursive function called eval-poly that takes a list of numbers representing the coefficients of a polynomial and a value for ? and evaluates the polynomial for the given value of ?. The list of coefficients should start with the term of lowest degree and end with the term of highest degree. If any term of intermediate degree is missing from the polynomial it should have a coefficient of zero. For example, the polynomial ?3+4?2+2 would be represented by the list '(2 0 4 1). Hint: the polynomial above can be rewritten as 2+?⋅(0+?⋅(4+?⋅1))
> (eval-poly '() 0)

0

> (eval-poly '(5) 0)

5

> (eval-poly '(4 3) 2)

10

> (eval-poly '(2 7 1) 3)

32

2.2 Write a tail-recursive version of the previous problem called eval-poly-tail. It should call a helper function called eval-poly-tail-helper that uses tail recursion to keep a running sum of the terms evaluated so far. You might want to use the expt function to take a number to a power.
> (eval-poly-tail '() 0)

0

> (eval-poly-tail '(5) 0)

5

> (eval-poly-tail '(4 3) 2)

10

> (eval-poly-tail '(2 7 1) 3)

32

Edit: This is all the information given.

In: Computer Science

Write a c++ program that inputs a time from the console. The time should be in...

Write a c++ program that inputs a time from the console. The time should be in the format “HH:MM AM” or “HH:MM PM”. Hours may be one or two digits. Your program should then convert the time into a four-digit military time based on a 24-hour clock.

Code:

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main() {

        string input;
        cout << "Enter (HH:MM XX) format time: ";
        getline(cin, input);

        int h, m;
        bool am;

        int len = input.size();

        char a=toupper(input.at(len-2)), b = toupper(input.at(len-1));
        if(a=='A' && b == 'M') {
                am = true;
        } else {
                am = false;
        }

        h = input.at(0) - '0';
        if(input.at(1) == ':') {
                input = input.substr(2);
        } else {
                h = 10*h + (input.at(1) - '0');
                input = input.substr(3);
        }

        m = input.at(0) - '0';
        if(input.at(1) != ' ') {
                m = 10*m + (input.at(1) - '0');
        }

        // 12AM means midnight, 12PM means afternoon
        if(h == 12) {
                h = 0;
        }
        if(!am) {
                h += 12;
        }
        cout << setw(2) << std::setfill('0') << h << m << " hours" << endl;
}

Is there any easier way and a simpler way to write the code other than the above code?

In: Computer Science

Analysis Study Case Question: Suppose that your computer only has enough memory to store 40000 entries....

Analysis Study Case Question:

  • Suppose that your computer only has enough memory to store 40000 entries. Which best graph data structure(s) – you can choose more than 1 -- should you use to store a simple undirected graph with 200 vertices, 19900 edges, and the existence of edge(u,v) is frequently asked?

–Adjacency Matrix

–Adjacency List

–Edge List

In: Computer Science

PYTHON!!! Radioactive materials decay over time and turn into other substances. For example, the most common...

PYTHON!!!

Radioactive materials decay over time and turn into other substances. For example, the most common isotope of uranium, U-238, decays into thorium-234 by emitting an alpha-particle. The rate of radioactive decay of a material is measured in terms of its half-life. The half-life of a material is defined to be the amount of time it takes for half of the material to undergo radioactive decay. Let m be the initial mass in grams of some material and let h be the material’s half-life in days. Then the remaining mass of the material on day t, denoted m(t), is given by the formula: m(t) = m × 0.5 t/h

Note: This formula is not a Python assignment statement! It is an equation that says: if you know the quantities m, t, and h, you can calculate a value using the right side of the equation. That value will be the amount of remaining mass of the material after t days. For this question, write a program which does the following: • Prompt the user to enter the initial mass of the material (in grams). You must make sure that the user enters a positive number. If they do not enter a positive number, print a message informing them so, and prompt them to enter the initial amount of material again. Keep doing this until they enter a positive number. • Prompt the user to enter the half-life of the material (in days). As above, make sure that the user enters a positive number, and if they don’t, keep asking until they do. • Starting from day 0, output the amount of the material remaining at one-day intervals. Thus, for day 0, day 1, day 2, etc., you should print out the amount of remaining mass according to the above formula. Your program should stop on the first day on which remaining mass is less than 1% of the initial mass. Don’t forget to import the math module if you need math functions. Hint: A correct solution should make use of three while-loops.

In: Computer Science

SLUGGING PERCENTAGES & BATTING AVERAGES - SENTINEL LOOP Develop a program in JAVA that will determine...

SLUGGING PERCENTAGES & BATTING AVERAGES - SENTINEL LOOP

Develop a program in JAVA that will determine the slugging percentages and batting average of several New York Yankees from the 2006 season.  Slugging percentage is calculated by dividing the total number of bases by the number of at bats.  The number of bases would be one for every single, two for every double, three for every triple, and four for every home run.  The batting average is calculated by dividing the total number of hits by the number of at bats.  You do not know the number of players in advance, but for each player you know their number of singles, doubles, triples, home runs, total number of at bats, and the player's name (use the proper type and method for each variable).

You will use a while sentinel loop on the 1st item to input.  If it is not the sentinel, go into the while sentinel loop and separately input the rest of the input items (be careful of the enter in the input memory buffer for the player name).  You will then calculate the total bases and the slugging percentage.  You will then calculate the batting average.  You will then print out the player's name, the labeled slugging percentage for that player to three decimal places, and the labeled batting average for that player to three decimal places.  Use separate output statements.  Print a blank line between players.  This loop will repeat for as many players as you need.

Run your program with the following players and sentinel value (to show the sentinel value worked):

Singles:  158

Doubles:  39

Triples:  3

Home Runs:  14

At Bats:  623

Player:  Derek Jeter

Singles:  51

Doubles:  25

Triples:  0

Home Runs:  37

At Bats:  446             

Player:  Jason Giambi                                                                                                          

Singles:  104

Doubles:  26

Triples:  1

Home Runs:  35

At Bats:  572             

Player:  Alex Rodriguez                                                                  

Singles: -1

In: Computer Science

Create the Database: The data is the same as was described in the ER Design Project...

Create the Database:

The data is the same as was described in the ER Design Project assignment. In that assignment you were asked to map the ER diagram to relations in the database. Here is a formal description of the relations that you will use in this assignment:

streamTV Database Relations

shows(showID, title, premiere_year, network, creator, category)

episode(showID, episodeID, airdate, title)

  • showID is a foreign key to shows

actor(actID, fname, lname)

main_cast(showID, actorID, role)

  • showID is a foreign key to shows
  • actID is a foreign key to actor

recurring_cast(showID, episodeID, actorID, role)

  • showID is a foreign key to shows episodeID is a foreign key to episode
  • actID is a foreign key to actor

customer(custID, fname, lname, email, creditcard,membersince,renewaldate, password, username)

cust_queue(custID, showID, datequeued)

  • custID is a foreign key to customer
  • showID is a foreign key to shows

watched(custID, showID, episodeID, datewatched)

  • custID is a foreign key to customer
  • showID is a foreign key to shows
  • (showID, episodeID) is a foreign key to episode
  • (custID, showID) is a foreign key to cust_queue

Primary keys are in bold.

Question:

SQL Queries:

The management at streamTV needs to retrieve certain information about their the data in the database. Specify the SQL queries for the questions listed here:

1. Find the titles and premiere years of all shows that were created after 2005.

2. Find the number of episodes watched by each customer, sorted by customer last name.

3. Find the names and roles of all actors in the main cast of Friday Night Lights.

4. Find all actors who are in the main cast of at least one show and in the recurring cast of at least one show. Display the actor's first name, last name, the title of the show in which the actor is in the main cast, the title of the show in which the actors is in the recurring cast, and the role the actor plays in each show.

5. How many shows have episodes with the word "good" in the title.

6. List the show title, episode number, date and episode title for all of the shows with the word "good" in the title. Sort the list by airdate.

7. Which episodes that have been watched originally aired in 2005. Display the show title, the episode title and the original air date.

8. Display the names of all actors who have had recurring roles in shows on NBC. Include the name of the actor, the title of the show and the role.

9. A customer wants to add to her queue every show that Amy Poehler has appeared in. List all of these shows by title.

10. For each customer (display first and last name), display which show and episode was the first one watched by that customer. Sort the result by the customer's last name.

11. Find all shows that have more than 5 seasons. Display the title of the show, and the number of seasons. Sort the result by the number of seasons. Note that the first digit of each episode number represents the season number.

12. Find the titles of all shows that were not watched by any customers in August of 2013.


13. List the title of the show that has been watched the most by customers. Also display the number of times it has been watched.

14. For each show, list the number of customers who have that show in their queue. Display the show title and the number of customers. Sort by show title.

In: Computer Science