Answer:
See explaination
Explanation:
#include <iostream>
#include <vector>
using namespace std;
// function to print configuration for each pitcher
void printConfig(vector<int> w, int n)
{
cout << "Current configuration: [" << w[0];
for(int i=1; i<n; i++)
{
cout << ", " << w[i];
}
cout << "]" << endl;
}
void getOptions(vector<int> c, vector<int> w, int n, vector<pair<int, pair<int, int>>> &options)
{
// options count
int count = 0;
// fill
for(int i=0; i<n; i++)
{
if(c[i] > w[i] && w[i] >= 0)
{
count ++;
cout << count << ". Fill pitcher " << (i+1) << endl;
// add options to list
options.push_back(make_pair(1, make_pair(i, 0)));
}
}
// empty
for(int i=0; i<n; i++)
{
if(c[i] >= w[i] && w[i] > 0)
{
count++;
cout << count << ". Empty pitcher " << (i+1) << endl;
// add options to list
options.push_back(make_pair(2, make_pair(i, 0)));
}
}
// Pour pitcher i to pitcher j
for(int i=0; i<n; i++)
{
if(c[i] >= w[i] && w[i] > 0)
{
for(int j=0; j<n; j++)
{
if(i!=j && c[j] > w[j] && w[j] >= 0)
{
count++;
cout << count << ". Pour pitcher " << (i+1) << " to " << (j+1) << endl;
// add options to list
options.push_back(make_pair(3, make_pair(i, j)));
}
}
}
}
}
void execute(vector<int> c, vector<int> &w, pair<int, pair<int, int>> option)
{
int i = option.second.first;
// for fill
if(option.first == 1)
{
w[i] = c[i];
}
// empty
else if(option.first == 2)
{
w[i] = 0;
}
// pour
else
{
int j = option.second.second;
if(w[i] >= c[j])
{
w[i] = w[i] - c[j];
w[j] = c[j];
}
else
{
w[j] = w[i];
w[i] = 0;
}
}
}
int main()
{
// required variables
int choice, n, temp, g, flag, moves = 0;
// vectors are dynamic sized arrays
vector<int> c, w;
vector<pair<int, pair<int, int>>> options;
// select puzzle
cout << "Select the puzzle to solve:\n";
cout << "1. Pitchers\n";
cout << "2. Eight puzzle\n";
cout << "Your selection: ";
cin >> choice;
if(choice == 1)
{
// input values required
cout << "Enter the number of pitchers: ";
cin >> n;
// array for pitchers
cout << "Enter the capacities of the " << n << " pitchers (gallons): ";
for(int i=0; i<n; i++)
{
cin >> temp;
c.push_back(temp);
w.push_back(0);
}
cout << "Enter the goal (gallons): ";
cin >> g;
// start game
while(true)
{
// print configuration
printConfig(w, n);
// check for goal state
flag = 0;
for(int i=0; i<n; i++)
{
if(w[i] == g)
{
flag = 1;
break;
}
}
if(flag)
{
cout << "Great! You have reached the goal in " << moves << " moves. Bye." << endl;
break;
}
// get and print options
//empty previous options
options.clear();
getOptions(c, w, n, options);
// ask for user's selection
cout << "Your selection: ";
cin >> choice;
// update moves
moves++;
// perform according to the selection
execute(c, w, options[choice-1]);
}
}
return 0;
}
Define a thread that will use a TCP connection socket to serve a client Behavior of the thread: it will receive a string from the client and convert it to an uppercase string; the thread should exit after it finishes serving all the requests of a client Create a listening TCP socket While (true) { Wait for the connection from a client Create a new thread that will use the newly created TCP connection socket to serve the client Start the new thread. }
Answer:
The primary intention of writing this article is to give you an overview of how we can entertain multiple client requests to a server in parallel. For example, you are going to create a TCP/IP server which can receive multiple client requests at the same time and entertain each client request in parallel so that no client will have to wait for server time. Normally, you will get lots of examples of TCP/IP servers and client examples online which are not capable of processing multiple client requests in parallel.
Explanation:
hope i helped
5.14 ◆ Write a version of the inner product procedure described in Problem 5.13 that uses 6 × 1 loop unrolling. For x86-64, our measurements of the unrolled version give a CPE of 1.07 for integer data but still 3.01 for both floating-point data. A. Explain why any (scalar) version of an inner product procedure running on an Intel Core i7 Haswell processor cannot achieve a CPE less than 1.00. B. Explain why the performance for floating-point data did not improve with loop unrolling.
Answer:
(a) the number of times the value is performs is up to four cycles. and as such the integer i is executed up to 5 times. (b)The point version of the floating point can have CPE of 3.00, even when the multiplication operation required is either 4 or 5 clock.
Explanation:
Solution
The two floating point versions can have CPEs of 3.00, even though the multiplication operation demands either 4 or 5 clock cycles by the latency suggests the total number of clock cycles needed to work the actual operation, while issues time to specify the minimum number of cycles between operations.
Now,
sum = sum + udata[i] * vdata[i]
in this case, the value of i performs from 0 to 3.
Thus,
The value of sum is denoted as,
sum = ((((sum + udata[0] * vdata[0])+(udata[1] * vdata[1]))+( udata[2] * vdata[2]))+(udata[3] * vdata[3]))
Thus,
(A)The number of times the value is executed is up to 4 cycle. And the integer i performed up to 5 times.
Thus,
(B) The floating point version can have CPE of 3.00, even though the multiplication operation required either 4 or 5 clock.
What is the fastest typing speed ever recorded? Please be specific!
Answer:
250 wpm for almost an hour straight. This was recorded by Barbara Blackburn in 1946.
How is a struck-by rolling object defined?
Answer:
Struck by rolling object is commonly defined as Struck-By Rolling Object Hazard because it was caused by rolling objects or any objects that moves in circular motion that could cause an injury or accident.
Explanation:
The equation of certain traveling waves is y(x.t) = 0.0450 sin(25.12x - 37.68t-0.523) where x and y are in
meters, and t in seconds. Determine the following:
(a) Amplitude. (b) wave number (C) wavelength. (d) angular frequency. (e) frequency: (1) phase angle, (g) the
wave propagation speed, (b) the expression for the medium's particles velocity as the waves pass by them, and (i)
the velocity of a particle that is at x=3.50m from the origin at t=21.os
Answer:
A. 0.0450
B. 4
C. 0.25
D. 37.68
E. 6Hz
F. -0.523
G. 1.5m/s
H. vy = ∂y/∂t = 0.045(-37.68) cos (25.12x - 37.68t - 0.523)
I. -1.67m/s.
Explanation:
Given the equation:
y(x,t) = 0.0450 sin(25.12x - 37.68t-0.523)
Standard wave equation:
y(x, t)=Asin(kx−ωt+ϕ)
a.) Amplitude = 0.0450
b.) Wave number = 1/ λ
λ=2π/k
From the equation k = 25.12
Wavelength(λ ) = 2π/25.12 = 0.25
Wave number (1/0.25) = 4
c.) Wavelength(λ ) = 2π/25.12 = 0.25
d.) Angular frequency(ω)
ωt = 37.68t
ω = 37.68
E.) Frequency (f)
ω = 2πf
f = ω/2π
f = 37.68/6.28
f = 6Hz
f.) Phase angle(ϕ) = -0.523
g.) Wave propagation speed :
ω/k=37.68/25.12=1.5m/s
h.) vy = ∂y/∂t = 0.045(-37.68) cos (25.12x - 37.68t - 0.523)
(i) vy(3.5m, 21s) = 0.045(-37.68) cos (25.12*3.5-37.68*21-0.523) = -1.67m/s.
What should the timing of transition slides be per minute?
Maintain the flow of the presentation to
slides per minute
Answer:
15 seconds
Explanation:
A presentation slide is supposed to be on for 15 seconds and stop to ask if anyone has any questions, if you are explaining something or reading alond with the slide it could be as long as you want it to be.
Answer:
4 slides per minute
Explanation:
Zoom Vacuum, a family-owned manufacturer of high-end vacuums, has grown exponentially over the last few years. However, the company is having difficulty preparing for future growth. The only information system used at Zoom is an antiquated accounting system. The company has one manufacturing plant located in Iowa; and three warehouses, in Iowa, New Jersey, and Nevada. The Zoom sales force is national, and Zoom purchases about 25 percent of its vacuum parts and materials from a single overseas supplier. You have been hired to recommend the information systems Zoom should implement in order to maintain their competitive edge. However, there is not enough money for a full-blown, cross-functional enterprise application, and you will need to limit the first step to a single functional area or constituency. What will you choose, and why?
Answer:A TPS focusing on production and manufacturing to keep production costs low while maintaining quality, and for communicating with other possible vendors. The TPS would later be used to feed MIS and other higher level systems.
Explanation:
You can use this area to create your resume.
Answer:
YOUR NAME
YOUR CITY, STATE, AND ZIP CODE
YOUR PHONE NUMBER
YOUR EMAIL
Professional Summary
Reliable, top-notch sales associate with outstanding customer service skills and relationship-building strengths. Dedicated to welcoming customers and providing comprehensive service. In-depth understanding of sales strategy and merchandising techniques. Dependable retail sales professional with experience in dynamic, high-performance environments. Skilled in processing transactions, handling cash, using registers and arranging merchandise. Maintains high-level customer satisfaction by smoothly resolving customer requests, needs and problems. Seasoned Sales Associate with consistent record of exceeding quotas in sales environments. Delivers exceptional customer service and product expertise to drive customer satisfaction ratings. Proficient in use and troubleshooting of POS systems.
Skills
Returns and Exchanges
Adaptable and Flexible
Excellent Written and Verbal Communication
Meeting Sales Goals
Strong Communication and Interpersonal Skills
Time Management
Cash Handling
Reliable and Responsible
Work History
March 2020 to September 2021
Goodwill OF YOUR STATE
Retail Sales Associate
Helped customers complete purchases, locate items and join reward programs.
Checked pricing, scanned items, applied discounts and printed receipts to ring up customers.
Folded and arranged merchandise in attractive displays to drive sales.
Greeted customers and helped with product questions, selections and purchases.
Organized store merchandise racks and displays to promote and maintain visually appealing environments.
Monitored sales floor and merchandise displays for presentable condition, taking corrective action such as restocking or reorganizing products.
Balanced and organized cash register by handling cash, counting change and storing coupons.
Trained new associates on cash register operations, conducting customer transactions and balancing drawer.
Answered questions about store policies and addressed customer concerns.
Issued receipts and processed refunds, credits or exchanges.
Maintained clean sales floor and straightened and faced merchandise.
Education
YOUR HIGH SCHOOL THAT YOU ATTEND
Languages
Spanish
Explanation:
THIS IS MY RESUME IF YOU HAVE MORE WORK EXPERIENCE THEN ADD IT AFTER THE GOODWILL. I GOT A 100% ON EDGE.
Implement the function pairSum that takes as parameters a list of distinct integers and a target value n and prints the indices of all pairs of values in the list that sum up to n. If there are no pairs that sum up to n, the function should not print anything. Note that the function does not duplicate pairs of indices
Answer:
Following are the code to this question:
def pairSum(a,x): #find size of list
s=len(a) # use length function to calculte length of list and store in s variable
for x1 in range(0, s): #outer loop to count all list value
for x2 in range(x1+1, s): #inner loop
if a[x1] + a[x2] == x: #condition check
print(x1," ",x2) #print value of loop x1 and x2
pairSum([12,7,8,6,1,13],13) #calling pairSum method
Output:
0 4
1 3
Explanation:
Description of the above python can be described as follows:
In the above code, a method pairSum is declared, which accepts two-parameter, which is "a and x". Inside the method "s" variable is declared that uses the "len" method, which stores the length of "a" in the "s" variable. In the next line, two for loop is declared, in the first loop, it counts all variable position, inside the loop another loop is used that calculates the next value and inside a condition is defined, that matches list and x variable value. if the condition is true it will print loop value.Write a program that has an input as a test score, and figures out a letter grade for that score, such as "A", "B", "C", etc. according to the scale: 90 or more - A 80 - 90 (excluding 90) - B 70 - 80 (excluding 80) - C 60 - 70 (excluding 70) - D else - F The program should print both a test score, and a corresponding letter grade. Test your program with different scores. Use a compound IF-ELSE IF statement to find a letter grade.
Answer:
The program in csharp for the given scenario is shown.
using System;
class ScoreGrade {
static void Main() {
//variables to store score and corresponding grade
double score;
char grade;
//user input taken for score
Console.Write("Enter the score: ");
score = Convert.ToInt32(Console.ReadLine());
//grade decided based on score
if(score>=90)
grade='A';
else if(score>=80 && score<90)
grade='B';
else if(score>=70 && score<80)
grade='C';
else if(score>=60 && score<70)
grade='D';
else
grade='F';
//score and grade displayed
Console.WriteLine("Score: "+score+ " Grade: "+grade);
}
}
OUTPUT1
Enter the score: 76
Score: 76 Grade: C
OUTPUT2
Enter the score: 56
Score: 56 Grade: F
Explanation:
1. The variables to hold the score and grade are declared as double and char respectively.
int score;
char grade;
2. The user is prompted to enter the score. The user input is not validated and the input is stored in the variable, score.
3. Using if-else-if statements, the grade is decided based on the value of the score.
if(score>=90)
grade='A';
else if(score>=80 && score<90)
grade='B';
else if(score>=70 && score<80)
grade='C';
else if(score>=60 && score<70)
grade='D';
else
grade='F';
4. The score and the corresponding grade are displayed.
5. The program can be tested for different values of score.
6. The output for two different scores and two grades is included.
7. The program is saved using ScoreGrade.cs. The .cs extension indicates a csharp program.
8. The whole code is written inside a class since csharp is a purely object-oriented language.
9. In csharp, user input is taken using Console.ReadLine() which reads a string.
10. This string is converted into an integer using Convert.ToInt32() method.
score = Convert.ToInt32(Console.ReadLine());
11. The output is displayed using Console.WriteLine() or Console.Write() methods; the first method inserts a line after displaying the message which is not done in the second method.
12. Since the variables are declared inside Main(), they are not declared static.
13. If the variables are declared outside Main() and at the class level, it is mandatory to declare them with keyword, static.
Donnell backed up the information on his computer every week on a flash drive. Before copying the files to the flash drive, he always ran a virus scan against the files to ensure that no viruses were being copied to the flash drive. He bought a new computer and inserted the flash drive so that he could transfer his files onto the new computer. He got a message on the new computer that the flash drive was corrupted and unreadable; the information on the flash drive cannot be retrieved. Assuming that the flash drive is not carrying a virus, which of the following does this situation reflect?
a. Compromise of the security of the information on the flash drive
b. Risk of a potential breach in the integrity of the data on the flash drive
c. Both of the above
d. Neither of the above.
Answer:
b. Risk of a potential breach in the integrity of the data on the flash drive
Explanation:
The corrupted or unreadable file error is an error message generated if you are unable to access the external hard drive connected to the system through the USB port. This error indicates that the files on the external hard drive are no longer accessible and cannot be opened.
There are several reasons that this error message can appear:
Viruses and Malware affecting the external hard drive .Physical damage to external hard drive or USB memory .Improper ejection of removable drives.3.15 LAB: Countdown until matching digits
Write a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical.
Ex: If the input is:
93
the output is:
93 92 91 90 89 88
Ex: If the input is:
77
the output is:
77
Ex: If the input is:
15
or any value not between 20 and 98 (inclusive), the output is:
Input must be 20-98.
#include
using namespace std;
int main() {
// variable
int num;
// read number
cin >> num;
while(num<20||num>98)
{
cout<<"Input must be 20-98 ";
cin>> num;
}
while(num % 10 != num /10)
{
// print numbers.
cout<
// update num.
num--;
}
// display the number.
cout<
return 0;
}
I keep getting Program generated too much output.
Output restricted to 50000 characters.
Check program for any unterminated loops generating output
Answer:
See explaination
Explanation:
n = int(input())
if 20 <= n <= 98:
while n % 11 != 0: // for all numbers in range (20-98) all the identical
digit numbers are divisible by 11,So all numbers that
are not divisible by 11 are a part of count down, This
while loop stops when output digits get identical.
print(n, end=" ")
n = n - 1
print(n)
else:
print("Input must be 20-98")
Write the interface (.h file) of a class Counter containing: A data member counter of type int. A data member named counterID of type int. A static int data member named nCounters. A constructor that takes an int argument. A function called increment that accepts no parameters and returns no value. A function called decrement that accepts no parameters and returns no value. A function called getValue that accepts no parameters and returns an int. A function named getCounterID that accepts no parameters and returns an int.
Explanation:
See the attached image for The interface (.h file) of a class Counter
SUMMING THE TRIPLES OF THE EVEN INTEGERS FROM 2 THROUGH 10) Starting with a list containing 1 through 10, use filter, map and sum to calculate the total of the triples of the even integers from 2 through 10. Reimplement your code with list comprehensions rather than filter and map.
Answer:
numbers=list(range(1,11)) #creating the list
even_numbers=list(filter(lambda x: x%2==0, numbers)) #filtering out the even numbers using filter()
triples=list(map(lambda x:x*3 ,even_numbers)) #calculating the triples of each even number using map
total_triples=sum(triples) #calculatting the sum
numbers=list(range(1,11)) #creating the list
even_numbers=[x for x in numbers if x%2==0] #filtering out the even numbers using list comprehension
triples=[x*3 for x in even_numbers] #calculating the triples of each even number using list comprehension
total_triples=sum(triples) #calculating the sum.
Explanation:
Go to the page where you are going to write the code, name the file as 1.py, and copy and paste the following code;
numbers=list(range(1,11)) #creating the list
even_numbers=list(filter(lambda x: x%2==0, numbers)) #filtering out the even numbers using filter()
triples=list(map(lambda x:x*3 ,even_numbers)) #calculating the triples of each even number using map
total_triples=sum(triples) #calculatting the sum
numbers=list(range(1,11)) #creating the list
even_numbers=[x for x in numbers if x%2==0] #filtering out the even numbers using list comprehension
triples=[x*3 for x in even_numbers] #calculating the triples of each even number using list comprehension
total_triples=sum(triples) #calculating the sum
Design and implement the Heap.h header using the given Heap class below:
template
class Heap
public:
Heap();
Heap(const T elements[], int arraySize); //
Remove the root from the heap and maintain the heap property
T remove() throw (runtime_error);
// Insert element into the heap and maintain the heap property
void add(const T& element);
// Get the number of element in the heap
int getSize() const;
private:
vector v;
Removing the root in a heap - after the root is removed, the tree must be rebuilt to maintain the heap property:
Move the last node to replace the root;
Let the root be the current node;
While (the current node has children and the current node is smaller than one of its children) Swap the current node with the larger of its children; The current node now is one level down;}
Adding a new node - to add a new node to the heap, first add it to the end of the heap and then rebuild the tree as follows:
Let the last node be the current node;
While (the current node is greater than its parent)
{Swap the current node with its parent; The current node now is one level up:}
To test the header file, write the heapSort function and use the following main program:
#include
#include "Heap.h"
using namespace std;
template
void heapSort(T list[], int arraySize) 1/
your code here .. p
int main()
const int SIZE = 9;
int list[] = { 1, 2, 3, 4, 9, 11, 3, 1, 2 }; heapSort(list, SIZE);
cout << "Sorted elements using heap: \n";
for (int i = 0; i < SIZE; i++) cout << list[i] << " ";
cout << endl;
system("pause");
return;
Sample output:
Sorted elements using heap:
1 1 2 3 3 4 7 9 11
Answer:
See explaination
Explanation:
/* Heap.h */
#ifndef HEAP_H
#define HEAP_H
#include<iostream>
using namespace std;
template<class T>
class Heap
{
public:
//constructor
Heap()
{
arr = nullptr;
size = maxsize = 0;
}
//parameterized constructor
Heap(const T elements[], int arraySize)
{
maxsize = arraySize;
size = 0;
arr = new T[maxsize];
for(int i=0; i<maxsize; i++)
{
add(elements[i]);
}
}
//Remove the root from the heap and maintain the heap property
T remove() //code is altered
{
T item = arr[0];
arr[0] = arr[size-1];
size--;
T x = arr[0];
int parent = 0;
while(1)
{
int child = 2*parent + 1;
if(child>=size) break;
if(child+1 < size &&arr[child+1]>arr[child])
child++;
if(x>=arr[child]) break;
arr[parent] = arr[child];
parent = child;
}
arr[parent] = x;
return item;
}
//Insert element into the heap and maintain the heap property
void add(const T&element)
{
if(size==0)
{
arr[size] = element;
size++;
return;
}
T x = element;
int child = size;
int parent = (child-1)/2;
while(child>0 && x>arr[parent])
{
arr[child] = arr[parent];
child = parent;
parent = (child-1)/2;
}
arr[child] = x;
size++;
}
//Get the number of element in the heap
int getSize() const
{
return size;
}
private:
T *arr; //code is altered
int size, maxsize;
};
#endif // HEAP_H
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* main.cpp */
#include<iostream>
#include "Heap.h"
using namespace std;
template <typename T>
void heapSort(T list[], int arraySize)
{
Heap<T> heap(list, arraySize);
int n = heap.getSize();
for(int i=n-1; i>0; i--)
{
list[i] = heap.remove();
}
}
int main()
{
const int SIZE = 9;
int list[] = {1, 7, 3, 4, 9, 11, 3, 1, 2};
heapSort<int>(list, SIZE);
cout << "Sorted elements using heap: \n";
for (int i = 0; i < SIZE; i++)
cout << list[i] << " ";
cout <<endl;
system("pause");
return 0;
}
TRUE OR FALSE! HELP!!
Answer:
True
Explanation:
There's no one law that governs internet privacy.
Components of a product or system must be
1) Reliable
2) Flexible
3) Purposeful
4)Interchangeable
Answer:
The correct answer to the following question will be Option D (Interchangeable).
Explanation:
Interchangeability applies towards any portion, part as well as a unit that could be accompanied either by equivalent portion, component, and unit within a specified commodity or piece of technology or equipment.This would be the degree to which another object can be quickly replaced with such an equivalent object without re-calibration being required.The other three solutions are not situation-ally appropriate, so option D seems to be the right choice.
Write an expression to detect that the first character of userinput matches firstLetter.
import java.util.Scanner; public class CharMatching { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String userInput; char firstLetter; userInput = scnr.nextLine(); firstLetter = scnr.nextLine().charAt(0); if (/* Your solution goes here */) { System.out.println("Found match: " + firstLetter); } else { System.out.println("No match: " + firstLetter); } return; } }
Answer: Provided in the explanation segment
Explanation:
Below is the code to run this program.
we have that the
Program
import java.util.Scanner;
public class CharMatching {
public static void main(String[] args) {
//Scanner object for keyboard read
Scanner scnr=new Scanner(System.in);
//Variable for user input string
String userInput;
//Variable for firstletter input
char firstLetter;
//Read user input string
userInput=scnr.nextLine();
//Read first letter from user
firstLetter=scnr.nextLine().charAt(0);
//Comparison without case sensititvity and result
if(Character.toUpperCase(firstLetter)==Character.toUpperCase(userInput.charAt(0))) {
System.out.println("Found match: "+firstLetter);
}
else {
System.out.println("No match: "+firstLetter);
}
}
}
Output
Hello
h
Found match: h
cheers i hope this helped !!!
Write a program to read as many test scores as the user wants from the keyboard (assuming at most 50 scores). Print the scores in (1) original order, (2) sorted from high to low (3) the highest score, (4) the lowest score, and (5) the average of the scores. Implement the following functions using the given function prototypes: void displayArray(int array[], int size) - Displays the content of the array void selectionSort(int array[], int size) - sorts the array using the selection sort algorithm in descending order. Hint: refer to example 8-5 in the textbook. int findMax(int array[], int size) - finds and returns the highest element of the array int findMin(int array[], int size) - finds and returns the lowest element of the array double findAvg(int array[], int size) - finds and returns the average of the elements of the array
Answer: Provided in the explanation segment
Explanation:
Below is the code to carry out this program;
/* C++ program helps prompts user to enter the size of the array. To display the array elements, sorts the data from highest to lowest, print the lowest, highest and average value. */
//main.cpp
//include header files
#include<iostream>
#include<iomanip>
using namespace std;
//function prototypes
void displayArray(int arr[], int size);
void selectionSort(int arr[], int size);
int findMax(int arr[], int size);
int findMin(int arr[], int size);
double findAvg(int arr[], int size) ;
//main function
int main()
{
const int max=50;
int size;
int data[max];
cout<<"Enter # of scores :";
//Read size
cin>>size;
/*Read user data values from user*/
for(int index=0;index<size;index++)
{
cout<<"Score ["<<(index+1)<<"]: ";
cin>>data[index];
}
cout<<"(1) original order"<<endl;
displayArray(data,size);
cout<<"(2) sorted from high to low"<<endl;
selectionSort(data,size);
displayArray(data,size);
cout<<"(3) Highest score : ";
cout<<findMax(data,size)<<endl;
cout<<"(4) Lowest score : ";
cout<<findMin(data,size)<<endl;
cout<<"(5) Lowest scoreAverage score : ";
cout<<findAvg(data,size)<<endl;
//pause program on console output
system("pause");
return 0;
}
/*Function findAvg that takes array and size and returns the average of the array.*/
double findAvg(int arr[], int size)
{
double total=0;
for(int index=0;index<size;index++)
{
total=total+arr[index];
}
return total/size;
}
/*Function that sorts the array from high to low order*/
void selectionSort(int arr[], int size)
{
int n = size;
for (int i = 0; i < n-1; i++)
{
int minIndex = i;
for (int j = i+1; j < n; j++)
if (arr[j] > arr[minIndex])
minIndex = j;
int temp = arr[minIndex];
arr[minIndex] = arr[i];
arr[i] = temp;
}
}
/*Function that display the array values */
void displayArray(int arr[], int size)
{
for(int index=0;index<size;index++)
{
cout<<setw(4)<<arr[index];
}
cout<<endl;
}
/*Function that finds the maximum array elements */
int findMax(int arr[], int size)
{
int max=arr[0];
for(int index=1;index<size;index++)
if(arr[index]>max)
max=arr[index];
return max;
}
/*Function that finds the minimum array elements */
int findMin(int arr[], int size)
{
int min=arr[0];
for(int index=1;index<size;index++)
if(arr[index]<min)
min=arr[index];
return min;
}
cheers i hope this help!!!
Write the definition of a function words_typed, that receives two parameters. The first is a person's typing speed in words per minute (an integer greater than or equal to zero). The second is a time interval in seconds (an integer greater than zero). The function returns the number of words (an integer) that a person with that typing speed would type in that time interval.
//Method definition of words_typed
//The return type is int
//Takes two int parameters: typingSpeed and timeInterval
public static int words_typed(int typingSpeed, int timeInterval) {
//Get the number of words typed by
//finding the product of the typing speed and the time interval
//and then dividing the result by 60 (since the typing speed is in "words
// per minute" and the time interval is in "seconds")
int numberOfWords = typingSpeed * timeInterval / 60;
//return the number of words
return numberOfWords;
} //end of method declaration
Explanation:The code above has been written in Java and it contains comments explaining each of the lines of the code. Please go through the comments.
Answer:
I am writing the program in Python.
def words_typed(typing_speed,time_interval):
typing_speed>=0
time_interval>0
no_of_words=int(typing_speed*(time_interval/60))
return no_of_words
output=words_typed(20,30)
print(output)
Explanation:
I will explain the code line by line.
First the statement def words_typed(typing_speed,time_interval) is the definition of a function named words_typed which has two parameters typing_speed and time_interval.
typing_speed variable of integer type in words per minute.
time_interval variable of int type in seconds
The statements typing_speed>=0 and time_interval>0 means that value of typing_speed is greater than or equal to zero and value of time_interval is greater than zero as specified in the question.
The function words_typed is used to return the number of words that a person with typing speed would type in that time interval. In order to compute the words_typed, the following formula is used:
no_of_words=int(typing_speed*(time_interval/60))
The value of typing_speed is multiplied by value of time_interval in order to computer number of words and the result of the multiplication is stored in no_of_words. Here the time_interval is divided by 60 because the value of time_interval is in seconds while the value of typing_speed is in minutes. So to convert seconds into minutes the value of time_interval is divided by 60 because 1 minute = 60 seconds.
return no_of_words statement returns the number of words.
output=words_typed(20,30) statement calls the words_typed function and passed two values i.e 20 for typing_speed and 30 for time_interval.
print(output) statement displays the number of words a person with typing speed would type in that time interval, on the output screen.
Fill in the blanks to make the factorial function return the factorial of n. Then, print the first 10 factorials (from 0 to 9) with the corresponding number. Remember that the factorial of a number is defined as the product of an integer and all integers before it. For example, the factorial of five (5!) is equal to 1*2*3*4*5
Answer:
Following are code of factorial in python language
def factorial(n): # function
result=1 #variable
for x in range(2,n+1): #iterating the loop
result=result*x #storing result
return result #return result
for n in range(10): #iterating loop
print(n,factorial(n)) #print factorial
Output:
Following are the attachment of output
Explanation:
Missing information :
In the question the information is missing the code is missing which we have to correct it following are the code that are mention below.
def factorial(n): # function
result=1 #variable
for x in range( ): #iterating the loop
result= #storing result
return #return result
for n in range( ): #iterating loop
print(n,factorial(n)) #print factorial
Following are the description of code
We have create a function factorial in this we have pass the one parameter i.e "n".In the for loop we have pass 2,n+1 which has been used to iterating the loop calculating factorial and string the result in the result variable In the main function we have pass the range on which we have to calculated the factorialFinally the print function will print the factorial .Following are the attachment snip of code in the python language
By filling in the blanks to make the factorial function return the factorial of n, we have the following.
def factorial (n):
result = 1
for x in range(2, n+1):
result = result*x
return result
for n in range(10):
print(n,factorial(n))
The math module in Python includes a number series of mathematical operations that may be easily done using the module. The math . factorial() function computes the factorial of a given number.
To write the code perfectly and fill in the blanks:
We created a math factorial function with n parameterThis code is being passed through the iterating loop 2,n+1 for calculation. We string the result, perform the range, and print out the result using the print formula.CODE:
def factorial (n):
result=1
for x in range(2, n+1):
result = result*x
return result
for n in range(10):
print(n,factorial(n))
RESULT:
0 1
1 1
2 2
3 6
4 24
5 120
6 720
7 5040
8 40320
9 362880
Therefore, we can conclude that we've understood how to write the factorial function code in python.
Learn more about python coding here:
https://brainly.com/question/1351889?referrer=searchResults
Describe how DMA is
used to
transfer data
from peripherals.
Answer:
Think of DMA as a co-processor that is used to quickly transfer data between main memory and peripherals without the intervention of the CPU.
Write a static method named contains that accepts two arrays of integers a1 and a2 as
parameters and that returns a boolean value indicating whether or not a2's sequence of
elements appears in a1 (true for yes, false for no). The sequence of elements in a2 may
appear anywhere in a1 but must appear consecutively and in the same order. For example, if
variables called list1 and list2 store the following values:
int[] list1 = {1, 6, 2, 1, 4, 1, 2, 1, 8};
int[] list2 = {1, 2, 1};
Then the call of contains(list1, list2) should return true because list2's sequence of
values {1, 2, 1} is contained in list1 starting at index 5. If list2 had stored the values {2,
1, 2}, the call of contains(list1, list2) would return false because list1 does not
contain that sequence of values. Any two lists with identical elements are considered to contain
each other, so a call such as contains(list1, list1) should return true.
Answer:
Sew explaination foe code
Explanation:
import java.lang.*;
import java.util.*;
import java.io.*;
class Main
{
public static Boolean checkSubset(int[] list1, int[] list2)
{
int l = list2.length;
for(int i = 0; i<list1.length-l; i++)
{
Boolean flag = true;
for(int j = 0; j<list2.length; j++)
{
if(list1[i+j] != list2[j])
{
flag = false;
break;
}
}
if(flag) return true;
}
return false;
}
public static void main(String args[])
{
int[] l1 = {1,6,2,1,4,1,2,1,8};
int[] l2 = {1,2,2};
System.out.println(checkSubset(l1,l2));
}
}
3.34 LAB: Mad Lib - loops in C++
Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.
Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input is quit 0.
Ex: If the input is:
apples 5
shoes 2
quit 0
the output is:
Eating 5 apples a day keeps the doctor away.
Eating 2 shoes a day keeps the doctor away.
Make sure your answer is in C++.
Answer:
A Program was written to carry out some set activities. below is the code program in C++ in the explanation section
Explanation:
Solution
CODE
#include <iostream>
using namespace std;
int main() {
string name; // variables
int number;
cin >> name >> number; // taking user input
while(number != 0)
{
// printing output
cout << "Eating " << number << " " << name << " a day keeps the doctor away." << endl;
// taking user input again
cin >> name >> number;
}
}
Note: Kindly find an attached copy of the compiled program output to this question.
In this exercise we have to use the knowledge in computational language in C++ to describe a code that best suits, so we have:
The code can be found in the attached image.
What is looping in programming?In a very summarized way, we can describe the loop or looping in software as an instruction that keeps repeating itself until a certain condition is met.
To make it simpler we can write this code as:
#include <iostream>
using namespace std;
int main() {
string name; // variables
int number;
cin >> name >> number; // taking user input
while(number != 0)
{
// printing output
cout << "Eating " << number << " " << name << " a day keeps the doctor away." << endl;
// taking user input again
cin >> name >> number;
}
}
See more about C++ at brainly.com/question/19705654
Rewrite this if/else if code segment into a switch statement int num = 0; int a = 10, b = 20, c = 20, d = 30, x = 40; if (num > 101 && num <= 105) { a += 1; } else if (num == 208) { b += 1; x = 8; } else if (num > 208 && num < 210) { c = c * 3; } else { d += 1004; }
Answer:
public class SwitchCase {
public static void main(String[] args) {
int num = 0;
int a = 10, b = 20, c = 20, d = 30, x = 40;
switch (num){
case 102: a += 1;
case 103: a += 1;
case 104: a += 1;
case 105: a += 1;
break;
case 208: b += 1; x = 8;
break;
case 209: c = c * 3;
case 210: c = c * 3;
break;
default: d += 1004;
}
}
}
Explanation:
Given above is the equivalent code using Switch case in JavaThe switch case test multiple levels of conditions and can easily replace the uses of several if....elseif.....else statements.When using a switch, each condition is treated as a separate case followed by a full colon and the the statement to execute if the case is true.The default statement handles the final else when all the other coditions are falseHow can u refer to additional information while giving a presentation
Answer:
There are various ways: Handing out papers/fliers to people, or presenting slides.
3. You are working for a usability company that has recently completed a usability study of an airline ticketing system. They conducted a live AB testing of the original website and a new prototype your team developed. They brought in twenty participants into the lab and randomly assigned them to one of two groups: one group assigned to the original website, and the other assigned to the prototype. You are provided with the data and asked to perform a hypothesis test. Using the standard significance value (alpha level) of 5%, compute the four step t-test and report all important measurements. You can use a calculator or SPSS or online calculator to compute the t-test. (4 pts)
Answer:
Check the explanation
Explanation:
Let the population mean time on task of original website be [tex]\mu_1[/tex] and that of new prototype be [tex]\mu_2[/tex]
Here we are to test
[tex]H_0:\mu_1=\mu_2\;\;against\;\;H_1:\mu_1<\mu_2[/tex]
The data are summarized as follows:
Sample 1 Sample 2
Sample size n=20 n=20
Sample mean [tex]\bar{x}_1=243.4[/tex] [tex]\bar{x}_2=253.4[/tex]
Sample SD s1=130.8901 s2=124.8199
The test statistic is obtained from online calculator as
t=-0.23
The p-value is given by 0.821
As the p-value is more than 0.05, we fail to reject the null hypothesis at 5% level of significance and hence conclude that there is no statistically significant difference between the original website and the prototype developed by the team at 5% level of significance.
Which term describes the order of arrangement of files and folders on a computer?
File is the order of arrangement of files and folders.
Answer:
Term describes the order of arrangement of files and folders on a computer would be ORGANIZATION.
:) Hope this helps!
Answer:
The term that describes the order of arrangement of files and folders on a computer is organization.
Explanation:
Explain possible ways that Darla can communicate with her coworker Terry, or her manager to make sure Joe receives great customer service?
Answer:
They can communicate over the phone or have meetings describing what is and isn't working for Joe. It's also very important that Darla makes eye contact and is actively listening to effectively handle their customer.
Explanation:
Fill in the empty function so that it returns the sum of all the divisors of a number, without including it. A divisor is a number that divides into another without a remainder. in python
Program explanation:
In the given program code, a method "sum_divisors" is declared that takes "n" variable in its parameter.Inside the method, the "s" variable is declared, which holds a value which is "0", and used a for loop that defines counts the range values.In the loop, a conditional statement is declared that check remainder value equal to 0 and adds value in "s" variable and return its value.Program code:
def sum_divisors(n):#defining a method sum_divisors that takes a parameter
s = 0#defining a variable s that hold a value 0
for x in range(1,n):#defining a for loop that use n variable to check range value
if(n%x==0):#use if to check remainder value equal to 0
s += x#adding value in s variable
return s#return s value
print(sum_divisors(6))#calling method
print(sum_divisors(12))#calling method
Output:
Please find the attached file.
Learn more:
brainly.com/question/14704583