Questions
Please answer true or false for each statement. 1. An attribute that is a foreign key...

Please answer true or false for each statement.

1. An attribute that is a foreign key cannot have a null value.

2.The Excel spreadsheet’s data model is set-theoretic.

3.A candidate key is a property of a database that must always be unique for all relations in the database.

4. A table in Microsoft’s Access must have at least one column.

5. In the relational model, a relation schema is a set of tuples.

In: Computer Science

Program 1-100 integer accumulation using RISC-V assembly. Note: RARS only simulates 320-bit instructions of RISC-V, so...

Program 1-100 integer accumulation using RISC-V assembly.

Note: RARS only simulates 320-bit instructions of RISC-V, so make sure you use the instruction that operate work-size data type (mostly with `w` as the last character of the instruction mnemonic)

In: Computer Science

(Linked Lists) The Problem UCF is growing so large that they’re actually starting a mini-supermarket, KnightsMart,...

(Linked Lists)

The Problem

UCF is growing so large that they’re actually starting a mini-supermarket, KnightsMart, stocked with typical supermarket products along with all the studying essentials (selection of coffees and creamers, pallets upon pallets of Red Bull, and all the Twinkies you can imagine!).

KnightsMart is in need of a program that:

  • manages all products in the store, along with the stock (quantity) for that product
  • manages the reordering of depleted products (once the stock for that item reaches zero)
  • manages the total sales to all customers in a given day

Throughout any given day, the following things can occur (just as in a normal store):

  • New products can be added to the list of products. For example, perhaps the store doesn’t initially carry Cheerios. So this new product, Cheerios, can be added to the product line for KnightsMart. Note: when new products are added for the first time, they are initialized with a specific stock amount associated with that product. It is guaranteed that newly added items will always have a quantity of at least one unit.
  • Customers can come throughout the day to purchase items from the store. If the items are available, they are purchased, and the stock of those specific products are all reduced by the quantity purchased. If a product is not available (stock is zero), the customer simply does not purchase that product.
  • A purchase occurs when a customer finds at least one of the items they are looking for. All such purchases will need to be saved as described later in this write up. However, if a customer enters the store and all of the desired items have a stock of zero, this customer did not make a purchase, and therefore, does not need to be saved.
  • As customers purchase products, the quantity for that product is clearly reduced. Once the inventory level for a product reaches zero, that product is immediately added to a restock list.
  • Reorders can be made, and they will be based on the restock list. Products that are reordered will have their stock increased based on a fixed restock quantity associated with that particular product. For the sake of ease, whenever a REORDER command is given, we assume the restocking happens immediately (meaning, an order is not placed to some central warehouse, and then we wait for a delivery truck three days later, etc, etc.). So just assume that the items in the restock list are immediately (magically) restocked.

For this program, you will need to maintain three linked lists: a linked list of all products in the store, a linked list of products that need to be reordered, and a linked list of sales that occur on any given day.

You will read in a list of commands from an input file, and your program will execute those commands accordingly. The final command, for each day, will be one that prints out a summary for all sales in the given day, which is detailed in the input/output specifications.

Implementation

You will need to make use of the following structures (EXACTLY as shown):

     typedef struct KnightsMartProduct {

          int itemNum;      char itemName[21];      double unitPrice;      int stockQty;           int restockQty;

          struct KnightsMartProduct *next;

     } KMProduct;

     typedef struct KnightsMartRestockProduct {

          int itemNum;

          struct KnightsMartRestockProduct *next;

     } KMRestockProduct;

     typedef struct KnightsMartSale {      char firstName[21];

          char lastName[21];

          int numItemsOnList; // # of items on shopping list      int *itemsPurchased; // array of item numbers

          struct KnightsMartSale *next;     } KMSale;

You will need to make the following three linked lists:

  • KMProducts: this is an ordered linked list of products, where each node is a KMProduct (defined above). The products (nodes) of this list are in ascending order based on item number. So the first product in the list is the one whose item number is “smallest”, and the last product in the linked list is the one whose item number is largest. As such, insertion into this list must happen at the correct location, thereby maintaining the integrity of the order.
  • KMRestockList: this is a linked list of the products that need to be restocked. This list is initially NULL. Once the quantity of a product reaches zero, a new

KMRestockProduct node is made, and it is immediately added to the end of this list.

  • KMSales: this is a linked list of all the sales that occur during a given day, where each node is of type KMSale. At the beginning of each day, this list is initially NULL. Once a customer finds and therefore purchases at least one item, that sale is immediately added to the end of this list. If a customer enters the store and does not find any of the items they are looking for (all items had a current stock of zero), no sale occurred, and that customer is therefore not added to this list.

Input File Specifications

You will read in input from a file, "KnightsMart.in". Have this AUTOMATED. Do not ask the user to enter “KnightsMart.in”. You should read in this automatically. (This will expedite the grading process.). The first line of the file will be an integer, d, representing the number of days that the simulation will run. The first line of each simulation will be an integer, k, indicating the number of commands that will be run for that day’s simulation, with each command occurring on a separate line. Each of those k commands will be followed by relevant data as described below (and this relevant data will be on the same line as the command).

The commands you will have to implement are as follows:

  • ADDITEM – Makes a new product which is added to the store. The command will be followed by the following information all on the same line: itemNum, an integer representing the item number for this product; itemName, the name of the item, no longer than 20 characters; unitPrice, the price of a single item; stockQty, the initial amount of stock for this product (guaranteed to be at least 1); restockQty, the quantity by which the product should be restocked whenever a reorder is placed. Each item will be unique. Meaning, the input file is guaranteed to not have duplicate items added to the store inventory via the ADDITEM command.
  • RESTOCK – This command will have no other information on the line. When this command is read, all items found in the KMRestockList are to be restocked immediately. This proceeds as follows:

◦ You need to traverse the list using the method shown in class.

◦ For every product (node) in this KMRestockList list, you need to search for that item in the KMproducts list, which will allow you to restock that node accordingly.

◦ Once found, you will increase the stockQty member of that KMProduct based on the restockQty member of that same KMProduct.

◦ You then need to delete that particular product (node) from the KMRestockList. Note: since you delete from the KMRestockList as you traverse the list, this means that you will simply be deleting from the front of the list at all times. ◦ Assuming you follow these steps properly, once you’ve traversed the entire

KMRestockList, restocked all necessary products, and then deleted those products from the KMRestockList, at this point KMRestockList will have no nodes and should point to NULL (meaning, the list is empty).

  • CUSTOMER – This command is for customers attempting to make purchases. It is followed by the following on the same line: a first name, then a last name, each no longer than 20 characters; an integer, n, representing two times (2x) the number of different products the customer wants to purchase, followed by n integers, which will be pairs of item numbers and the respective quantity purchased of that item number. For example, if n were six, this means the customer wants three items. Pretend those following six integers were as follows: 5437 2 8126 1 9828 4. This means the customer wants 2 units of product 5437, 1 unit of 8126, and 4 units of product number 9828.

As mentioned previously, a purchase occurs when a customer finds, and of course then buys, one of the items on their shopping list. When this happens, a KMSale node must be made, which records this sale. The struct members must then be filled in accordingly. One member of the KMSale node is itemsPurchased. This is an array that must be dynamically allocated based on the size (number) on the original shopping list. If the product is found and purchased, the item number is added to the corresponding cell of this array, along with the quantity purchased. We assume that if the stock for a given item is available, the customer will purchase the full desired quantity on their shopping list (of that item). If the product is not found, a zero is recorded in that cell of the array. Based on the three-item example above, if the first and third items were available, with the second being unavailable (no stock), the itemsPurchased array would have SIX cells as follows: 5437, 2, 8126, 0, 9828, 4. This shows that 2 units of 5437 were purchased, and 4 units of 9828 were purchased; the zero after item 8126 simply shows that the item was not available. Finally, once all appropriate information is saved into the struct members of the KMSale node, this node is then added to the end of the KMSales list. Note: a line of output is printed regardless of whether or not a purchase was made. Refer to sample output for examples.

  • INVENTORY – This command will have no other information on the line. When this command is read, the current KnightsMart inventory (each item with its respective stock) is printed to the file in ascending order (the order that the product list is already in). See sample output file for specific formatting of this command. If there store does not have any inventory, an appropriate error message is printed (see sample output).
  • PRINTDAYSUMMARY – This command will have no other information on the line. When this command is read, a eport of all sales, for that given day, will be printed to the output file. Please refer to sample output for exact specifications. Once the header is printed (see sample output), all sales (nodes) found in the KMSales list will need to be printed, and then those nodes must be deleted. This will proceed as follows:

◦ You need to traverse the list using the method shown in class.

◦ For every Sale (node) in the KMSales list, you need to print Sale number (starting at 1), along with the first and last name of the customer (in that order). You then need to print the list of items that were successfully found and then purchased. Finally, you need to print the total amount paid. Please refer to the EXACT output format for specifics.

◦ After printing the appropriate information, you then need to delete that particular Sale (node) from the KMSales list. Note: since you delete from the KMSales list as you traverse the list, this means that you will simply be deleting from the front of the list at all times. This also means that the first Sale (node) in the list will be both the first Sale printed and the first Sale deleted.

◦ Assuming you follow these steps properly, once you’ve traversed the entire KMSales list, printed all necessary information, and then deleted those Sales from the KMSales list, at this point the KMSales list will have no nodes and should point to NULL (meaning, the list is empty).

◦ Lastly, you must print out the total sales (dollar amount) for the given day.

Status of Lists at the end of each day:

At the end of each day, the KMSales list will clearly be empty, as per the description in the PRINTDAYSUMMARY command. This prints each Sale, deletes each node, effectively destroying that list. The other two lists, KMProducts and KMRestockList, will be maintained throughout the entire running of your program. Meaning, you clearly should not destroy (delete all nodes from) the list of products in the store at the end of a day, as this would result in there being no products in the store for subsequent days. Additionally, the

KMRestockList will also be maintained over the simulation. This means that if there were items in the KMRestockList at the end of a given day, those items will remain in that list at the beginning of the next day, thereby allowing them to be restocked whenever a REORDER command arrives.

Output Format

Your program must output to a file, called "KnightsMart.out". You must follow the program specifications exactly. You will lose points for formatting errors and spelling.

When examining the output file, you should notice that the INVENTORY command and the PRINTDAYSUMMARY command results in printing a “semi-formatted” line of text. To avoid guessing games and to guarantee the correctness of your format, we are providing those two print literals below:

Here is the literal for printing inventory items in the INVENTORY command:

"\t| Item %6d | %-20s | $%7.2lf | %4d unit(s) |\n"

And here is the literal for printing customer items in the PRINTDAYSUMMARY command:

"\t\t| Item %6d | %-20s | $%7.2lf (x%4d) |\n"

In: Computer Science

SQL allows duplicate tuples in relations, and correspondingly defines the multiplicity of tuples in the result...

SQL allows duplicate tuples in relations, and correspondingly defines the multiplicity of tuples in the result of joins. Which of the following queries always gives the same answer as the nested query shown below?

select * from R where a in (select S.a from S);

select R.* from R,S where R.a = S.a;

select R.* from R, (select distinct a from S) as S1 where R.a = S1.a;

select R.* from R,S where R.a = S.a and is unique R;

select distinct R.* from R,S where R.a = S.a;

In: Computer Science

When writing code in any language, it is always a good idea to work in a...

When writing code in any language, it is always a good idea to work in a modular fashion. In this approach you will write a small piece of code (usually a small logical module), and test to ensure it works. If it does, you will add more code, and test it again. This way, if the program were to crash after you last addition, you will know where to look for bugs. Debugging a few lines of code is much easier than typing pages of code and then trying to debug that. Please use this approach while working at your programming assignments.

In this assignment you will write a small program that demonstrates that you can manipulate a string. You can hardcode a string of your choice in your code, that is, create a variable and assign it a string "Mary had a little chicken". Then you will use string functions to manipulate it. Keep in mind that to test your program I will enter my own string into your code. So, your program has to work for all possible strings and produce correct output.

First, echo the string on the screen, and then print it backwards using a string function. Figure out how to count the total number of letters in the string using functions provided in the chapter, and the number of vowels and consonants. For this exercise, please treat letter "y" as a vowel. Your output should look exactly like this:

Original string:   Mary had a little chicken
Reversed string: nekcihc elttil a dah yraM
Total letters: 21
Vowels: 8
Consonants: 13

Save your script as mystringyourlastname.php and submit to BB via submission portal before the deadline. Be sure to thoroughly test your code on xampp server with Internet Explorer and/or Firefox. I will be using xampp to test your submission. Test your assignment with various input strings to ensure it operates correctly. I will check different strings to make sure you have done error checking.

Please plan to have enough time for testing and debugging. I will nor be debugging your code for you. Please keep in mind that I ALWAYS read you code, so do not forget to format it nicely and use comments, as points will be deducted for such violations. Program that does not work will receive ZERO credit, as it is pointless to produce a program that does not work. Partial credit for depend on the existing functionality, per rubric below.

In: Computer Science

In Verilog Design a state machine, using the D flip-flop, that implements a 00 and 11...

In Verilog

Design a state machine, using the D flip-flop, that implements a 00 and 11 sequence detector. Your machine should output a 1 as soon as it detects two 0s or two 1s on its input, otherwise it outputs 0s.
Write a module that implements the machine and a test bench to test it.

In: Computer Science

language python use a functions and write a python of a computer with three power operations:...

language python




use a functions and write a python of a computer with three power operations: power by two, power by three, and power by four.

input a number and operation (^2,^3,or^4).

output: the result of the power operation

In: Computer Science

I. Malicious software can be classified by propagation method or payload. Explain the difference between the...

I. Malicious software can be classified by propagation method or payload. Explain the difference between the three common propagation methods: worm, virus and social engineering;

II. Explain the difference between a normal virus, a metamorphic virus and a polymorphic virus, including discussing how easy they are to detect by anti-virus software

In: Computer Science

System Design and Analysis Analyze and design a hotel reservation system - Should include the following...

System Design and Analysis

Analyze and design a hotel reservation system -

Should include the following

- Create a Data Flow Diargram that includes Context Diagram and DFD 0
- Create a Use Case Diagram and include 8 fully-dressed use cases.

In: Computer Science

Write a thesis with not less than 5000 word Cloud services and its uses for good...

Write a thesis with not less than 5000 word

Cloud services and its uses for good governance in Developing countries.

In: Computer Science

Suppose an algorithm A1 has a runtime T1(n) defined ( in seconds) by the following function...

Suppose an algorithm A1 has a runtime T1(n) defined ( in seconds) by the following function

T1(n) = n3 + 20n + 15

For n = 13, the runtime of the algorithm is 2472 seconds. Let us assume that we have an algorithm A2 with runtime given by T2(n) = n2 + 22n + 14? What will be the lowest value of n for which the runtime of A2 exceeds 2472 seconds?

**Urgently needed**

In: Computer Science

What a "base” use case is? DQ 7-1 OOA

What a "base” use case is?

DQ 7-1 OOA

In: Computer Science

Q1. under what circumstances would static hashing be better than extendible hashing? Q2. under what circumstances...

Q1. under what circumstances would static hashing be better than extendible hashing?

Q2. under what circumstances would extendible hashing be better than static hashing?

In: Computer Science

Develop Python implementation of combinatorial algorithm which will find all possible Anagrams of user input. Hint:...

  • Develop Python implementation of combinatorial algorithm which will find all possible Anagrams of user input. Hint: use backtracking algorithm.
  • Example:
  • Input = ROWAN UNIVERSITY
  • Output (298 possibilities):
  • YOUR WINTERS VAIN
  • OAT RUINS WIN VERY
  • ROAR TUNES WIN IVY
  • IRONY UNWISER VAT
  • TIE IN SUN ROW VARY…

In: Computer Science

Chapter 7, Problem 3PE from Introduction to Programming using Python by Y. Daniel Liang. Problem (The...

Chapter 7, Problem 3PE from Introduction to Programming using Python by Y. Daniel Liang.

Problem

(The Account class) Design a class named Account that contains:

■ A private int data field named id for the account.

■ A private float data field named balance for the account.

■ A private float data field named annualInterestRate that stores the current interest rate.

■ A constructor that creates an account with the specified id (default 0), initial balance (default 100), and annual interest rate (default 0).

■ The accessor and mutator methods for id, balance, and annualInterestRate.

■ A method named getMonthlyInterestRate() that returns the monthly interest rate.

■ A method named getMonthlyInterest() that returns the monthly interest.

■ A method named withdraw that withdraws a specified amount from the account.

■ A method named deposit that deposits a specified amount to the account.

Draw the UML diagram for the class, and then implement the class. (Hint: The method getMonthlyInterest() is to return the monthly interest amount, not the interest rate. Use this formula to calculate the monthly interest: balance * monthlyInterestRate. monthlyInterestRate is annualInterestRate / 12. Note that annualInterestRate is a percent (like 4.5%). You need to divide it by 100.)

Write a test program that creates an Account object with an account id of 1122, a balance of $20,000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2,500, use the deposit method to deposit $3,000, and print the id, balance, monthly interest rate, and monthly interest.

In: Computer Science