Write a method named minimumValue, which returns the smallest value in an array that is passed (in) as an argument. The method must use Recursion to find the smallest value. Demonstrate the method in a full program, which does not have to be too long regarding the entire code (i.e. program). Write (paste) the Java code in this word file (.docx) that is provided. (You can use additional pages if needed, and make sure your name is on every page in this word doc.) Use the following array to test the method: int[] series array = {-5, -10, +1999, +99, +100, +3, 0, +9, +300, -200, +1, -300} Make sure that the series array only tests for values, which are positive, given your recursive method.
Part II (25 points) Algorithmic Performance as you are aware, consists (mainly) of 2 dimensions: Time and Space. From a technical perspective, discuss the following: Regarding runtime, discuss algorithmic performance with respect to its runtime performance. As you develop an algorithm, what must you also consider in terms of some of the trade-offs? How would you go about estimating the time required for an algorithm’s efficiency (i.e. time to complete in terms of its potential complexity)? What techniques can you use? Give an example of how to measure it.
In: Computer Science
What are the data structures. How these are useful in different fields of computer science. Discuss at least three fields.
In: Computer Science
printf("You have entered %d arguments.\n", argc);
for (int i = 0; i < argc; ++i)
printf( "argument %d: %s\n",i+1,argv[i]);
please help me, this is c programming. thank you in advance.
In: Computer Science
The purpose of this assignment is to analyze data and use it to provide stakeholders with potential answers to a previously identified business problem.
For this assignment, continue to assume the role of a data analyst at Adventure Works Cycling Company. Evaluate the data associated with the drop in sales for the popular model "LL Road Frame-Black 60." Provide a hypothesis on what could be contributing to the falling sales identified in the initial business problem presented by your manager.
In 250-500 words, share these recommendations in a Word document that addresses the following.
In: Computer Science
1 Problem Description
This lab will cover a new topic: linked lists. The basic idea of a linked list is that an address or a pointer value to one object is stored within another object. By following the address or pointer value (also called a link), we may go from one object to another object. Understanding the pointer concept (which has be emphasized in previous labs and assignments) is crucial in understanding how a linked list operates.
Your task will be to add some code to manipulate the list.
2 Purpose
Understand the concept of linked lists, links or pointers, and how to modify a linked list.
3 Design
A very simple design of a node structure and the associated linked list is provided lab7.cpp. Here is the declaration:
typedef int element_type; struct Node { element_type elem; Node * next; Node * prev; // not used for this lab }; Node * head;
NOTE: A struct is conceptually the same thing as a class. The only significant difference is that every item (each method and data field) is public. Structs are often used as simple storage containers, while classes encompass complex data and methods on that data. Nodes of a linked list are good examples of where a struct would be useful.
Since head is a pointer that points to an object of type Node, head->elem ( or (*head).elem ) refers to the elem field. Similarly, head->next refers to the next field, the value of which is a pointer and may point to another node. Thus, we are creating a chain of Nodes. Each node points to the next Node in the chain.
Note that in our program head should always points to the first node of the linked list. For a linked list that has no elements (an empty list), the value of head is NULL. When working with linked lists, it is usually helpful to draw them out in order to understand their operation.
4 Implementation
Note that this file contains a show() function that will display the contents of a linked list in order. As with previous labs, you must call show() after each of the following steps.
Please write in C++
Basic Linked Lists Starter Code:
#include <cstdlib> #include <iostream> using namespace std; // Data element type, for now it is int, but we could change it to anything else // by just changing this line typedef int element_type; // Basic Node structure struct Node { element_type elem; // Data Node * next; // Pointer to the next node in the chain Node * prev; // Pointer to the previous node in the chain, not used for lab 7 }; // Print details about the given list, one Node per line void show(Node* head) { Node* current = head; if (current == NULL) cout << "It is an empty list!" << endl; int i = 0; while (current != NULL) { cout << "Node " << i << "\tElem: " << '\t' << current->elem << "\tAddress: " << current << "\tNext Address: " << current->next << endl; current = current->next; i++; } cout << "----------------------------------------------------------------------" << endl; } int main() { const int size = 15; Node* head = new Node(); Node* current = head; // Create a linked list from the nodes for (int i = 0; i < size; i++) { current->elem = i; current->next = new Node(); current = current->next; } // Set the properties of the last Node (including setting 'next' to NULL) current->elem = size; current->next = NULL; show(head); // TODO: Your Code Here Please use show(head); after completing each step. STEP 1: STEP 2: STEP3: STEP 4: // Clean up current = head; while (current != NULL) { Node* next = current->next; delete current; current = next; } return 0; }
In: Computer Science
Write a javascript code to Create a function called
Hotel that takes Room no, Customer name. amount paid. Write a code
to call hotel function for each customer and display details of
customers lodging in rooms with even room numbers.
I need only js and html code. no css
pls take screenshot of output , else I might dislike
thanks
In: Computer Science
Define a class for the student record. The class should instance variables for Quizzes, Midterm, Final and total score for the course and final letter grade.
The class should have input and output methods. The input method should not ask for the final numeric grade, nor should it ask for final letter grade. The classes should have methods to compute the overall numeric grade and the final letter grade. These two methods will be void methods that set the appropriate instance variables.
Make sure to add default constructor.
Your program should use all the described methods. You should have set of Accessor(getter) and mutator(setter) methods for all instance variables, whether your program uses them or not.
The program should read in the students’ scores two quizzes, midterm and final and display the student’s records, which consists of all the above +final number and final letter grade.
Overall numeric grade is calculated as 50%-final exam, 25%-midterm and two quizzes together count for 25%.
For letter grade
90-100 is A
80-89 is B
70-79 is C
60-69 is D
And any grade <60 is F grade
When taking input, quiz grades are out of 10 points and midterm and final are out of 100 points.
In: Computer Science
In: Computer Science
Implementation of a a queue with a "circular" array or a "regular" array.
(a) "circular" array: consider using the smallest number of fields/variables in a struct/class. List the fields/variables that support the enqueue and dequeue operations in O(1) time in the worst case. Explain why the list is the smallest and the two operations are O(1) time.
(b) "regular" array: explain the worst-case time complexity in big-O for the operations (queue size is at most n).
In: Computer Science
Assume that the following relationships were created in a database. CUSTOMER (CustomerNumber, CustomerLastName, CustomerFirstName, Phone) COURSE (CourseNumber, CourseTitle, TeachingMode, CourseCreationDate, Fee) ENROLLMENT (EnrollmentID, CustomerNumber, CourseNumber, EnrollmentDate, AmountPaid) Legend: Primary Key Foreign Key Possible values TeachingMode: PRE - Presencial, ONL - Online Write the SQL (ORACLE) statements required to complete what is required below. Provide ONE instruction per request / question. Write your answers in the space provided. Identify each answer with the corresponding request / question number. 1. Create the CUSTOMER table include the constraints 2. Create the COURSE table include the constraints 3. Create the ENROLLMENT table include the constraints 4. Create the sequence seqEnroll 5. Insert a row in the CUSTOMER table. 6. Insert a row in the COURSE table. 7. Insert a row in the ENROLLMENT table. The primary key field is a substitute (Surrogate / Artificial) so it will use the sequence you created in statement 4. The transaction must belong to the CUSTOMER you created in # 5 and the COURSE you created in # 6. 8. List customers in ascending alphabetical order by last name. Include the following information in this order: last name, first name and telephone number 9. List all the courses that have the word Pastels in the title. Include all the data in the COURSE table. 10. List all the courses the clients are enrolled in. Include the following data in this order: CustomerNumber, CourseNumber, and AmountPaid. 11. List all courses that started on or before October 1, 2018. Include the following data in this order: CourseDate, CourseNumber, CourseTitle, Fee. 12. Show for each client the total paid for classroom courses and total paid for online courses TeachingMode the total paid by each client. Show courses that are cheaper than the average price Use subquery and functions. 13. List all course information if you have had at least ten clients enrolled in the past twelve months. It must work at any time, the twelve-month period will depend on the date the consultation is run. DO NOT USE SPECIFIC DATES. Use subquery and functions.
In: Computer Science
Hello, I need an expert answer for one of my JAVA homework assignments. I will be providing the instructions for this homework below:
For this lab, you will write the following files:
As you can expect, AbstractDataCalc is an abstract class, that AverageDataCalc, MaximumDataCalc and MinimumDataCalc all inherit.
We will provide the following files to you:
Sample Input / Output
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Given the following CSV file
1,2,3,4,5,6,7 10,20,30,40,50,60 10.1,12.2,13.3,11.1,14.4,15.5
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The output of the provided main is:
Dataset Results (Method: AVERAGE) Row 1: 4.0 Row 2: 35.0 Row 3: 12.8 Dataset Results (Method: MIN) Row 1: 1.0 Row 2: 10.0 Row 3: 10.1 Dataset Results (Method: MAX) Row 1: 7.0 Row 2: 60.0 Row 3: 15.5
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Specifications
You will need to implement the following methods at a minimum. You are free to add additional methods.
AbstractDataCalc
AverageDataCalc
Extends AbstractDataCalc. Will implement the required constructor and abstract methods only.
MaximumDataCalc
Extends AbstractDataCalc. Will implement the required constructor and abstract methods only.
MinimumDataCalc
Extends AbstractDataCalc. Will implement the required constructor and abstract methods only.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CSVReader.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class CSVReader {
private static final char DELIMINATOR =
',';
private Scanner fileScanner;
public CSVReader(String file) {
this(file, true);
}
public CSVReader(String file, boolean
skipHeader) {
try {
fileScanner = new Scanner(new File(file));
if(skipHeader) this.getNext();
}catch (IOException io)
{
System.err.println(io.getMessage());
System.exit(1);
}
}
public List<String> getNext() {
if(hasNext()){
String toSplit = fileScanner.nextLine();
List<String> result = new ArrayList<>();
int start = 0;
boolean inQuotes = false;
for (int current = 0; current < toSplit.length(); current++)
{
if (toSplit.charAt(current) == '\"') { // the char uses the '', but
the \" is a simple "
inQuotes = !inQuotes; // toggle state
}
boolean atLastChar = (current == toSplit.length() - 1);
if (atLastChar) {
result.add(toSplit.substring(start).replace("\"", "")); // remove
the quotes from the quoted item
} else {
if (toSplit.charAt(current) == DELIMINATOR && !inQuotes)
{
result.add(toSplit.substring(start, current).replace("\"",
""));
start = current + 1;
}
}
}
return result;
}
return null;
}
public boolean hasNext() {
return (fileScanner !=
null) && fileScanner.hasNext();
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DataSet.java
import java.util.ArrayList;
import java.util.List;
public class DataSet {
private final List<List<Double>>
data = new ArrayList<>();
public DataSet(String fileName) {
this(new
CSVReader(fileName, false));
}
public DataSet(CSVReader csvReader) {
loadData(csvReader);
}
public int rowCount() {
return
data.size();
}
public List<Double> getRow(int i) {
return
data.get(i);
}
private void loadData(CSVReader file) {
while(file.hasNext())
{
List<Double> dbl = convertToDouble(file.getNext());
if(dbl.size()> 0) {
data.add(dbl);
}
}
}
private List<Double>
convertToDouble(List<String> next) {
List<Double>
dblList = new ArrayList<>(next.size());
for(String item : next)
{
try {
dblList.add(Double.parseDouble(item));
}catch (NumberFormatException ex) {
System.err.println("Number format!");
}
}
return dblList;
}
public String toString() {
return
data.toString();
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Main.java
public class Main {
public static void main(String[] args) {
String testFile =
"sample.csv";
DataSet set = new
DataSet(testFile);
AverageDataCalc averages
= new AverageDataCalc(set);
System.out.println(averages);
MinimumDataCalc minimum
= new MinimumDataCalc(set);
System.out.println(minimum);
MaximumDataCalc max =
new MaximumDataCalc(set);
System.out.println(max);
}
}
In: Computer Science
Create an Employee class having the following functions and
print
the final salary in c++ program.
- getInfo; which takes the salary, number of hours of work per
day
of employee as parameters
- AddSal; which adds $10 to the salary of the employee if it is
less
than $500.
- AddWork; which adds $5 to the salary of the employee if the
number of hours of work per day is more than 6 hours.
In: Computer Science
Having those files please adjust the following tasks.
When the user fills out the registration, all information is inserted into a database table.
When the user signs in, all information is verified from the database table.
You can either create your own table on your machine or use the demo server table for testing. Remember the table name and the fields must be exactly as shown below.
If you are using your own table, you must change the connection info as shown below before uploading to the demo server. Then you must test to make sure it works correctly on the demo server.
The table name will be 'account'.
The fields in the table are:
username - 20 char
password - 50 char
name - 20 char
email - 50 char
Make sure that all field names are the same upper and lowercase letters as shown above.
The password will still be encrypted when stored in the database.
You must insert data into the table using your program. Do not assume anything is on the table.
When creating userids and passwords, use something unique, as your classmates will be sharing the same table.
assignment3
<?php
session_start();
if(isset($_SESSION['userid']))
{
header("Location:home.php");
}
include 'header.php';
?>
<?php
if(isset($_POST["register"]))
{
// collect form data
$first_name=$_POST["first_name"];
$last_name=$_POST["last_name"];
$email=$_POST["email"];
$userid=$_POST["userid"];
$password=$_POST["password"];
$verify_password=$_POST["verify_password"];
if($password===$verify_password) // password verification
{
$hashFormat="$2y$10$"; // set hash
$salt ="iusesomecrazystrings22"; // set salt
$new_salt = $hashFormat . $salt; // concatenate hash and salt
$encrypted_password = crypt($password,$new_salt); // Encrypt the
password
if(file_exists("users.txt")) // check file is exist or not
{
// Open a file for write only and append the data to an existing
file
$myfile = fopen("users.txt", "a");
$mydata=$first_name."|".$last_name."|".$email."|".$userid."|".$encrypted_password."\r\n";
fwrite($myfile, $mydata);
include('send_mail.php');
}
else
{
$myfile = fopen("users.txt", "w"); // Open a file for write
only
fwrite($myfile, "First Name |Last Name | Email| User Id | Password\r\n");
$mydata=$first_name."|".$last_name."|".$email."|".$userid."|".$encrypted_password."\r\n";
fwrite($myfile, $mydata);
include ("send_mail.php");
}
fclose($myfile);
// set the message if password is verified
$register_msg = "The following registration information has been
successfully submitted";
}
else
{
$register_msg = "password not match"; // set the message if
password is not verified
}
}
else
{
$register_msg = "";
}
?>
<html>
<body>
<h1> <?php echo $register_msg; ?> </h1>
<form action="assignment3.php" method="POST"
style="float:left; width:50%;">
<fieldset>
<legend style="text-align: center;">User
Information</legend>
<table style="margin:0px auto;">
<tr>
<td>
<label> First Name</label>
</td>
<td>
<input type="text" name="first_name">
</td>
</tr>
<tr>
<td>
<label> Last Name</label>
</td>
<td>
<input type="text" name="last_name">
</td>
</tr>
<tr>
<td>
<label> Email</label>
</td>
<td>
<input type="email" name="email">
</td>
</tr>
<tr>
<td>
<label> User ID</label>
</td>
<td>
<input type="text" name="userid">
</td>
</tr>
<tr>
<td>
<label> Password</label>
</td>
<td>
<input type="password" name="password"
pattern="(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,12}" title="Must
contain at least one number and one special character, and length
must between 8 to 12 characters">
</td>
</tr>
<tr>
<td>
<label> Verify Password</label>
</td>
<td>
<!--create a password field for Verify Password -->
<input type="password" name="verify_password"
pattern="(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,12}" title="Must
contain at least one number and one special character, and length
must between 8 to 12 characters">
</td>
</tr>
<tr>
<td><input type="submit" name="register"
value="Register"></td>
<td><input type="reset" name="reset"
value="Reset"></td>
</tr>
</table>
</fieldset>
</form>
<form action="home.php" method="POST" style="float:right;
width:50%;">
<fieldset>
<legend style="text-align: center;">Sign
In</legend>
<table style="margin:0px auto;">
<tr>
<td>
<label> User ID</label>
</td>
<td>
<input type="text" name="userid">
</td>
</tr>
<tr>
<td>
<label> Password</label>
</td>
<td>
<input type="password" name="password"
pattern="(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,12}" title="Must
contain at least one number and one special character, and length
must between 8 to 12 characters">
</td>
</tr>
<tr>
<td><input type="submit" name="Submit"
value="Submit"></td>
<td><input type="reset" name="reset"
value="Reset"></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
header.php
<!DOCTYPE html>
<html>
<head>
<title>Assignment3</title>
<link rel="stylesheet" type="text/css" href="main.css"
/>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
</head>
<body>
<header>
<h1>Register for an Account</h1>
</header>
home.php
<?php
session_start();
if(!isset($_POST["Submit"])&&!isset($_SESSION["userid"]))
{
header("Location:assignment3.php");
}
if(isset($_POST['logout']))
{
session_unset();
// destroy the session
session_destroy();
header("Location:assignment2.php");
}
if(isset($_POST["Submit"])) // if Submit parameter exist
{
// collect form data
$userid=$_POST["userid"];
$password=$_POST["password"];
$hashFormat="$2y$10$"; // set hash
$salt ="iusesomecrazystrings22"; // set salt
$new_salt = $hashFormat . $salt; // concatenate hash and salt
$encrypted_password = crypt($password,$new_salt); // Encrypt the password entered by the user
$myfile = file ('./users.txt');
foreach($myfile as $row)
{
$data = explode("|",$row);
// Compare the userid and password to what is in the text file
if($userid===$data[3] &&
$encrypted_password===trim($data[4]))
{
// Set session variables
$_SESSION['userid'] = $data[3]; // Set userid to session
variable
$_SESSION['password'] = $data[4]; // Set password to session
variable
// If password match, set display a welcome message to variable
$msg="Welcome ".$_SESSION['userid'];
}
else
{
// If password do not match, set display this message to
variable
$msg="userid/password combo incorrect please reenter";
}
}
}
else
{
$msg="";
}
?>
<html>
<body>
<h1> <?php echo $msg; ?> </h1>
<?php
if(isset($_SESSION["userid"]))
{
?>
<form action="home.php" method="post">
<input type="submit" value="Sign Out" name="logout">
</form>
<?php
}
?>
</body>
</html>
css file
html {
background-color: #e6f2ff;
}
body {
font-family: Arial, Helvetica, sans-serif;
width: 900px;
margin: 0 auto;
padding: 0 1em;
background-color: white;
border: 1px solid blue;
}
header {
border-bottom: 2px solid black;
padding: .5em 0;
}
header h1 {
color: blue;
}
main {
}
aside {
float: left;
width: 150px;
}
h1 {
font-size: 150%;
margin: 0;
padding: .5em 0 .25em;
}
h2 {
font-size: 120%;
margin: 0;
padding: .75em 0 0;
}
h1, h2 {
color: black;
}
fieldset {
margin: 1em;
padding-top: 1em;
margin-left: 10px;
border: 1px solid blue;
}
label {
float: left;
width: 10em;
text-align: right;
margin-top: .25em;
margin-bottom: .5em;
}
input, select {
margin-left: 0.5em;
margin-bottom: 0.5em;
width: 14em;
}
br {
clear: both;
}
span {
vertical-align: middle;
}
.error {
color: #cc3300;
}
.notice {
color: #cc3300;
font-size: 50%;
text-align: right;
}
In: Computer Science
In C:
You are to create a program to request user input and store the data in an array of structures, and then display the data as requested. The data you are collecting refers to a set of images. The images are OCT images taken of the lining of the bladder. The data you provide will help diagnose the image as cancerous or not, but your code does not need to do that at the moment.
1) Define a global structure that contains the following information:
a) File number (must be >0)
b) Diagnosis number (1-8)
c) Number of layers in the image
d) Maximum average intensity of a single row (should be a float)
e) Width of brightest layer
2) Declare an array of 9 of the structures in #1. This array should be a global variable.
3) Initialize each of the file numbers in the array to -1.
4) Create a loop that will continue asking the user for the above data until the file number 0 is given, or until information has been provided for 9 images.
5) If the user provides a file number less than 0, ask again. Do not ask for further information if the user provides a file number equal to 0.
6) If the user provides a diagnosis number that is not between 1 and 8, ask again.
7) Store the data in the array of structures in the order it is provided.
8) Write a function to display the information for a particular file number. If the file number was not found, nothing is displayed. The function will return a 1 if the file number was found or a 0 if the file number was not in the array.
9) In your main function, after the loop which requests the data, create another loop that will request a file number from the user and then call the function written for #8 to display the data for that file number. This loop will continue until a file number is provided that is not found.
10) In your main function, after the code for #9, add a loop that will display the information for all items stored in the array in order.
In: Computer Science
In: Computer Science