Using the data in the following array write a program that finds and outputs the highest value, the lowest value, the count of elements in the array, the average value in the array, and the mode - the value that appears most often.
dataArray = {173.4, 873.7, 783.9. 000.0, -383.5, 229.5, -345.5, 645.5, 873.7, 591.2};
In: Computer Science
CREATE TABLE alp_orderline
(order_id int not null,
inv_id int not null,
order_price decimal(6,2) not null,
qty smallint not null,
primary key(order_id, inv_id));
INSERT into alp_orderline
VALUES(1, 1, 274.99, 1);
INSERT into alp_orderline
VALUES(1, 6, 32.95, 2);
INSERT into alp_orderline
VALUES(2, 10, 64.95, 1);
INSERT into alp_orderline
VALUES(3, 16, 15.99, 1);
INSERT into alp_orderline
VALUES(3, 18, 15.99, 1);
INSERT into alp_orderline
VALUES(4, 23, 199.95, 1);
INSERT into alp_orderline
VALUES(5, 21, 15.99, 2);
INSERT into alp_orderline
VALUES(5, 7, 32.95, 1);
INSERT into alp_orderline
VALUES(6, 10, 64.95, 1);
INSERT into alp_orderline
VALUES(6, 26, 209.95, 1);
In: Computer Science
Python: write a program to first ask how many tests a student
has taken, then collect all the test scores and calculate the
average score. After displaying the average score, the program also
assigns a letter grade to the student according to the following
grading scale:
Score Grade >=90 A 80-89 B 70-79 C 60-69 D <60 F This program
should perform input validation for test scores and only accept a
positive input value as a score (ask the user to enter another
value if input is invalid). The program should be able to handle
real numbers as test scores and display the average score with two
decimal digits.
The following is a Sample output of the program. How many tests did you take? 3 Enter a Test Score: -80 Error: test score must be positive. Try again 80 Enter a Test Score: 85.5 Enter a Test Score: 92.5 Your Average Score: 86.00 Your Grade: B
In: Computer Science
In: Computer Science
import java.util.ArrayList;
import java.util.Collections;
import java.lang.Exception;
public class ItemList
{
/** This is the main process for the project */
public static void main ()
{
System.out.println("\n\tBegin Item List Demo\n");
System.out.println("Declare an ArrayList to hold Item
objects");
ArrayList list = new ArrayList();
try
{
System.out.println("\n Add several Items to the list");
list.add(new Item(123, "Statue"));
list.add(new Item(332, "Painting"));
list.add(new Item(241, "Figurine"));
list.add(new Item(126, "Chair"));
list.add(new Item(411, "Model"));
list.add(new Item(55, "Watch"));
System.out.println("\nDisplay original Items list:");
listItems(list);
int result = -1;
// 1. TO DO: change the XXX to a number in the list, and YYY to a
number
// not in the list (1 Pt)
System.out.println("\nLinear Search list for items XXX and
YYY:");
// 2. TO DO: code a call to linearSearch with the item number
(XXX)
// that is in the list; store the return in the variable result (2
Pts)
if(result >= 0)
// 3. TO DO: change both XXX numbers to the number searched for (1
Pt)
System.out.printf("Item XXX found at pos %d\n", result);
else
System.out.printf("Item XXX not found in list\n");
// 4. TO DO: code a call to linearSearch with the item number
(yyy)
// that is not in the list; store the return in the variable result
(2 Pts)
if(result >= 0)
// 5. TO DO: change both YYY to the number searched for (1
Pt)
System.out.printf("Item YYY found at pos %d\n", result);
else
System.out.printf("Item YYY not found in list\n");
System.out.println("\nSort list into Item Number
sequence");
// 6. TO DO: code to sort the array using the Collections class (5
Pts)
System.out.println("\nDisplay the Sorted Items list:");
listItems(list);
// 7. TO DO: change the AAA to a number in the list, and BBB to
a number
// not in the list (use two different numbers) (1 Pt)
System.out.println("\nBinary Search list for items AAA and
BBB5:");
// 8. TO DO: code a call to binarySearch with the item number
(AAA)
// that is in the list; store the return in the variable result (3
Pts)
if(result >= 0)
// 0. TO DO: change both AAA numbers to the number searched for (1
Pt)
System.out.printf("Item AAA found at pos %d\n", result);
else
{
System.out.printf("Item AAA not found in list\n");
System.out.printf("Should be at pos %d\n", -result -1); // note
conversion
}
// 10. TO DO: code a call to binarySearch with the item number
(BBB)
// that is not in the list; store the return in the variable result
(3 Pts)
if(result >= 0)
// 11. TO DO change both BBB numbers to the number searched for (1
Pt)
System.out.printf("Item BBB found at pos %d\n", result);
else
{
System.out.println("Item BBB not found in list");
System.out.printf("Should be at pos %d\n", -result -1); // note
conversion
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
System.out.println("\n\tEnd Item List Demo\n");
}
/**
* This function performs a linear seach of the list
* @param list - reference to the ArrayList to be searched
* @param number - item number to seek
* @return i - index where item number wass found, -1 if not
found
*/
public static int linearSearch(ArrayListlist, int number)
{
for (int i = 0; i < list.size(); i++)
if(list.get(i).getItemNo() == number)
return i;
return -1;
}
/**
* This method traverses the Item list and displays the items
* @param list - reference to the ArrayList of Item Objects
*/
public static void listItems(ArrayList list)
{
for (Item item : list)
System.out.println(item.toString());
}
/**
* This recursive method finds a value in a range of a sorted
ArrayList,
* using a binary search algorithm.
* @param list - reference to the ArrayList in which to search
* @param key - the object key value to find
* @return the index at which the key occurs,
* or -n - 1 if it does not occur in the array
* n is the position in which the key object should appear
*/
public static int binarySearch(ArrayList list, int key)
{
int low = 0;
int high = list.size() - 1;
int pos = 0;
while (high >= low)
{
pos = (low + high) / 2;
if (key < list.get(pos).getItemNo())
high = pos - 1;
else if (key == list.get(pos).getItemNo())
return pos;
else
low = pos + 1;
}
return -low - 1;
}
}
import java.lang.Exception;
public class Item implements Comparable<Item>
{
/** The Item's identification number */
private int itemNo;
/** The Item's descriptive text */
private String itemDesc;
/**
* Constructs a default Item object
*/
public Item()
{
itemNo = 0;
itemDesc = "";
}
/**
* Parameter constructor for objects of class Item
* @param number - the Item's number
* @param desc - the Item's description
*/
public Item(int number, String desc) throws Exception
{
setItemNo(number);
setItemDesc(desc);
}
/**
* This method returns the Item identification number
* @return itemNo - the Item's number
*/
public int getItemNo()
{
return itemNo;
}
/**
* Tis method returns the Item's description
* @return itemDesc - the Item's descriptive text
*/
public String getItemDesc()
{
return itemDesc;
}
/**
* This method sets the Item's identification number.
* It accepts a number change if and only if the current number is
zero(0).
* Otherwise it throws an Exception
* @param number - the Item's new number
* @throw Exception, if number is invalid for this operation
*/
public void setItemNo(int number) throws Exception
{
if (itemNo == 0)
if (number > 0)
itemNo = number;
else
throw new Exception("Item number must be greater than zero(0)");
else
throw new Exception("An existing item number cannot be
changed!");
}
/**
* This method sets the Item's description
* @param desc - the Item's descriptive text
* @throws Exception if input desc is blank or null
*/
public void setItemDesc(String desc) throws Exception
{
if(desc.trim().length() > 0)
itemDesc = desc;
else
throw new Exception("Item description cannot be blank");
}
/**
* This method determines if one Item equals another
* @param other - the other Item to be matched
* @return true, if numbers are equal, false if not.
*/
public boolean equals(Item other)
{
return (itemNo == other.itemNo);
}
/**
* Provides the compareTo() method for the Comparable
Interface
* @param otherObject - the other object for comparison
* @returns a: positive value, if this number is greater than the
other
* negative value, if this number is less than the other
* zero, if the numbers are equal to each other
*/
@Override
public int compareTo(Item other)
{
return itemNo - other.itemNo;
}
/**
* This method overrides the toSting() method of Object
* Its purpose is to expose the data elements of the Product
* object in String form
* @return String - a string containing the Item's information
*/
@Override
public String toString()
{
return String.format("%4d %-25s", itemNo, itemDesc);
}
}
In: Computer Science
This database experience project has two parts: (1) creating the presentation-layer ERD, (2) developing the semantic integrity constraints (meta-data) for your data. The deliverable will include a title page with your name, your client’s name, and all sections as part of one file (.pdf).
Review the business rules described in your project files and create a presentation-layer ERD illustrating the entities/relationships needed to support your database design with accompanying data definitions. Use any graphical tool you prefer but be consistent. No gridlines – keep it clean.
Make sure to follow all rules of ER diagramming. If you see additional files (e.g., patient visit form, initial medical history form), you need to consider including the data from those forms into your database model as well. Include all entities, label relationships if there are multiple relationships between 2 entities, include all attributes and constraints where necessary and identify all primary and foreign keys as discussed.
For full credit, part 1 deliverable must include:
Semantic Integrity Constraints (or Data definitions) must be in the form of a table (use format shown below – do not add any other info columns), defining briefly each attribute of each entity, for each table. For example:
ENTITY |
Attribute |
Definition |
STUDENT |
StudentID |
12-digit number uniquely identifying the student, assigned by UH, not based on SSN or other ID |
STUDENT |
FirstName |
(required), character data, max-length 30 |
STUDENT |
MI |
Middle initial (optional), max-length 1 |
STUDENT |
LastName |
(required), character data, max-length 30 |
STUDENT |
AcctBalance |
Outstanding balance owed to the university for tuition, fees, etc. New registrants start at $0.00; 2 decimal places |
GRADES |
StudentID |
12-digit number uniquely identifying the student, assigned by UH, not based on SSN or other ID |
Data definitions for all attributes must be included; data-type and max length as a minimum requirement. (if the attribute is obvious such as first name, no need to define as “first name” etc.)
In: Computer Science
A developer was tasked to building a login / authentication
system for a website. He creates a table,
USER that has the user-name, and password stored in a database
table. He then creates a web-page
that prompts the user to enter in his user-id and password. On the
server side, the developer takes the
two pieces of information (user-id and password) and invokes the
following query:
Select * from USER where user =’$username’ and
password=’$password’
You are tasked on performing a peer review on this development.
What two pieces of feedback would
you give him, and how would you recommend addressing them?
In: Computer Science
PHP
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:
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
Answers will be given extra reward
Convert the following SINGLYLINKEDLIST code into DOUBLYLINKEDLIST code. Such that
struct Node {
int element;
structNode*next;
structNode*prev;
}
struct Node *head = NULL;
structNode*tail =NULL;
The SINGLYLINKEDLIST code is as follows:
#include <stdio.h>
#include <stdlib.h>
struct Node{
int element;
struct Node *next;
};
void get(struct Node *head, int pos)
{
struct Node *temp;
temp = head;
if(head == NULL)
{
printf("List is empty!\n");
}
for(int i=0; i < pos; i++)
temp = temp->next;
printf("The element is %d\n", temp->element);
}
void printList(struct Node *head)
{
struct Node *temp = head;
if(head == NULL)
printf("The list is empty\n");
else
{
printf("\nList: ");
while(temp != NULL)
{
printf("%d ", temp->element);
temp = temp->next;
}
}
}
struct Node * removeElement(struct Node *head, int
position)
{
struct Node *temp, *prev;
temp = head;
prev = NULL;
if(head == NULL)
printf("The list is empty!\n");
else
{
for(int i = 0; i < position; i++)
{
prev = temp;
temp = temp->next;
}
prev->next = temp->next;
free(temp);
}
return head;
}
struct Node *reverseList(struct Node *head)
{
struct Node *temp, *prev, *next;
temp = head;
prev = NULL;
next = NULL;
while(temp != NULL)
{
next = temp->next;
temp->next = prev;
prev = temp;
temp = next;
}
head = prev;
return head;
}
struct Node * insertLast(struct Node *head, int element)
{
struct Node *newNode, *temp;
temp = head;
newNode = (struct Node *) malloc(sizeof(struct Node));
newNode->element = element;
newNode->next = NULL;
if(head == NULL)
head= newNode;
else
{
while(temp->next != NULL)
temp = temp->next;
temp->next = newNode;
}
return head;
}
int sizeList(struct Node *head)
{
struct Node *temp = head;
int sizeL = 1;
if(head == NULL)
return 0;
else
{
while(temp->next != NULL)
{
temp = temp->next;
sizeL++;
}
}
return sizeL;;
}
int main(int argc, const char * argv[]) {
struct Node *head = NULL;
head = insertLast(head, 1);
head = insertLast(head, 2);
head = insertLast(head, 3);
head = insertLast(head, 4);
head = insertLast(head, 5);
head = insertLast(head, 6);
printList(head);
get(head, 2);
head = removeElement(head, 2);
printList(head);
get(head, 2);
printf("\nThe size of the list is %d\n", sizeList(head));
head = reverseList(head);
printList(head);
return 0;
}
In: Computer Science
%Purpose:
%Fit a first degree polynomial,
%a second-degree polynomial,
%and a third-degree polynomial to these data
%Plot all three plots (along with the original data points)
%together on the same plot and determine the BEST fit
%After determining the best fit add additional code to the end of
your script
%to predict the pressure at t = 11 seconds from the best-fitting
curve
%INPUT VARIABLES:
t = 1:0.05:10;
p = [26.1,27,28.2,29,29.8,30.6,31.1,31.3,31,30.5];
d1 = polyfit( t, p, 1 ); %first degree
d2 = polyfit( t, p, 2 ); %second degree
d3 = polyfit( t, p, 3 ); %third degree
t1 = 1:0.05:10;
p1 = polyval(d1,t1);
p2 = polyval(d2,t1);
p3 = polyval(d3,t1);
%
%OUTPUT VARIABLES:
%plot(t,p,'o') original data points
%plot(t, p1,)first degree
%plot(t, p2,)second degree
%plot(t, p3, '--')third degree
%title ('Fuel Line Pressure Predictions');
%xlabel('Time (sec)');
%ylabel('Pressure (psi)');
%
%OUTPUT SECTION:
plot(t,p,'o')
plot(t1,p1);
plot(t1,p2);
plot(t1,p3,'--');
title ('Fuel Line Pressure Predictions')
xlabel('Time (sec)')
ylabel('Pressure (psi)')
I am not sure what is wrong with my code. The errors that pop up are:
Error using polyfit (line 44)
The first two inputs must have the same number of elements.
Error in EngrProb_1 (line 17)
d1 = polyfit( t, p, 1 ); %first degree
In: Computer Science
A transport layer protocol uses the id of the process rather than the port number to specify the destination. (Explain the reason)
1. Is there any problem for senders who wish to connect to a well-defined service (for example, Apachewebserver)?
2. Will there be any problems with the process of multiple network connections?
3. If the host has a different operating system, will there be any problem?
In: Computer Science
4.
An identifier name in a program may represent
Group of answer choices
a location
a specific machine memory address
a value
all of the above
none of the above
In order for a language to support unbounded length character strings, it must have:
Group of answer choices
static storage allocation
dynamic storage allocation
static type checking
dynamic type checking
Suppose that the vehicle registration department for the State of Florida is becoming decentralized. Each county will now handle its own registration process and will issue its own license plates. However, there needs to be some centralized checking so that counties do not duplicate plate design, etc. Counties also need to notify each other if an address listed for a registration is not within their county.
The county systems must also interface with State systems for tax and other purposes. So, while the system will be mostly decentralized, there will still exist a need for centralized data access.
A consulting firm was hired to develop this system and they have narrowed the choice of programming language to Java and C#.
What do you think about their choice of programming
languages?
How would you evaluate their choice of these programming
languages?
In: Computer Science
In: Computer Science
Using this 1000-digit string:
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450
Write the following method: public static int
largestValue(String str)
1. Take a single String parameter
2. Work from the beginning to the end of the string,
3. identify the five-character group that represents the largest
five-digit number.
4. The method is then to return the largest five digit value in the
String as an integer.
Note:
1. Only one 5-digit group is to be identified and returned, so if
two or more identical values are in the string, only one of those
values is to be returned.
2. Each 5-digit group is built upon every single digit in the group
(less the final four digits), so the first two five-digit groups
will be the following: 73167, 31671, and so on. The last five-digit
group will be 63450.
3. Must use the String class substring( ) method to solve the above
problem.
4. The five-digit groups are to be evaluated as integers, and the
value of the largest five-digit number is to be returned as an
integer.
PLEASE HELP ME UNDERSTAND HOW TO COMPLETE THIS METHOD OR WHERE TO LEARN MORE I AM LOST HERE THANK YOU, BELOW IS WHAT A START:
public class Problem2StarterFile
{
public static void main(String [] args)
{
//variable declarations
String s = "73167176531330624919225119674426574742355349194934"
+
"96983520312774506326239578318016984801869478851843" +
"85861560789112949495459501737958331952853208805511" +
"12540698747158523863050715693290963295227443043557" +
"66896648950445244523161731856403098711121722383113" +
"62229893423380308135336276614282806444486645238749" +
"30358907296290491560440772390713810515859307960866" +
"70172427121883998797908792274921901699720888093776" +
"65727333001053367881220235421809751254540594752243" +
"52584907711670556013604839586446706324415722155397" +
"53697817977846174064955149290862569321978468622482" +
"83972241375657056057490261407972968652414535100474" +
"82166370484403199890008895243450658541227588666881" +
"16427171479924442928230863465674813919123162824586" +
"17866458359124566529476545682848912883142607690042" +
"24219022671055626321111109370544217506941658960408" +
"07198403850962455444362981230987879927244284909188" +
"84580156166097919133875499200524063689912560717606" +
"05886116467109405077541002256983155200055935729725" +
"71636269561882670428252483600823257530420752963450";
System.out.println("The largest value is: " + largestValue(s));
}
public static int largestValue(String str)
{
//PLEASE HELP ME UNDERSTAND HOW TO COMPLETE THIS METHOD OR WHERE TO
LEARN MORE I AM LOST HERE THANK YOU
return(0);
}
}
In: Computer Science
In: Computer Science