1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
UNO [17]
2 years ago
10

You want to read input from the user to know how many apples they would like

Computers and Technology
1 answer:
Daniel [21]2 years ago
6 0

Answer:

var applesToBuy = readLine("How many apples would you lik

e? ");

Explanation:

It asks the user to enter answer the question and it stores the answer into the applesToBuy variable.

Its right dont worry.

You might be interested in
Suppose that you want to write a program that inputs customer data and displays a summary of the number of customers who owe mor
Allushta [10]

Answer:

The correct option is D = regionNumber

Explanation:

In this scenario we want to know customers who owe more than $1000 each, in each of 12 sales regions. And the customer data variables include name, zip-code, balanceDue and regionNumber; based on the customer data variables names and zip-code will not really affect our output. It is based on balanceDue that we increment the number of customer owing in a particular region (regionNumber).

Therefore, we would add 1 to an array element whose subscript would be represented by regionNumber since we are interested to know the number of customer owing in each of the 12 sales regions.

3 0
2 years ago
6.5 Code Practice: Question 1 please help with code!!! Thank you
viva [34]

Answer: Eat my boy toy

Explanation:

7 0
3 years ago
g Write a program to sort an array of 100,000 random elements using quicksort as follows: Sort the arrays using pivot as the mid
shtirl [24]

Answer:

header.h->function bodies and header files.

#include<iostream>

#include<cstdlib>

#include<ctime>

using namespace std;

/* Partitioning the array on the basis of piv value. */

int Partition(int a[], int bot, int top,string opt)

{

int piv, ind=bot, i, swp;

/*Finding the piv value according to string opt*/

if(opt=="Type1 sort" || opt=="Type3 sort")

{

piv=(top+bot)/2;

}

else if(opt=="Type2 sort" || opt=="Type4 sort")

{

piv=(top+bot)/2;

if((a[top]>=a[piv] && a[top]<=a[bot]) || (a[top]>=a[bot] && a[top]<=a[piv]))

piv=top;

else if((a[bot]>=a[piv] && a[bot]<=a[top]) || (a[bot]>=a[top] && a[bot]<=a[piv]))

piv=bot;

}

swp=a[piv];

a[piv]=a[top];

a[top]=swp;

piv=top;

/*Getting ind of the piv.*/

for(i=bot; i < top; i++)

{

if(a[i] < a[piv])

{

swp=a[i];

a[i]=a[ind];

a[ind]=swp;

ind++;

}

}

swp=a[piv];

a[piv]=a[ind];

a[ind]=swp;

return ind;

}

void QuickSort(int a[], int bot, int top, string opt)

{

int pindex;

if((opt=="Type3 sort" || opt=="Type4 sort") && top-bot<19)

{

/*then insertion sort*/

int swp,ind;

for(int i=bot+1;i<=top;i++){

swp=a[i];

ind=i;

for(int j=i-1;j>=bot;j--){

if(swp<a[j]){

a[j+1]=a[j];

ind=j;

}

else

break;

}

a[ind]=swp;

}

}

else if(bot < top)

{

/* Partitioning the array*/

pindex =Partition(a, bot, top,opt);

/* Recursively implementing QuickSort.*/

QuickSort(a, bot, pindex-1,opt);

QuickSort(a, pindex+1, top,opt);

}

return ;

}

main.cpp->main driver file

#include "header.h"

int main()

{

int n=100000, i;

/*creating randomized array of 100000 numbers between 0 and 100001*/

int arr[n];

int b[n];

for(i = 0; i < n; i++)

arr[i]=(rand() % 100000) + 1;

clock_t t1,t2;

t1=clock();

QuickSort(arr, 0, n-1,"Type1 sort");

t2=clock();

for( i=0;i<n;i++)

arr[i]=b[i];

cout<<"Quick sort time, with pivot middle element:"<<(t2 - t1)*1000/ ( CLOCKS_PER_SEC );

cout<<"\n";

t1=clock();

QuickSort(arr, 0, n-1,"Type2 sort");

t2=clock();

for( i=0;i<n;i++)

arr[i]=b[i];

cout<<"Quick sort time, with pivot median element:"<<(t2 - t1)*1000/ ( CLOCKS_PER_SEC );

cout<<"\n";

t1=clock();

QuickSort(arr, 0, n-1,"Type3 sort");

t2=clock();

for( i=0;i<n;i++)

arr[i]=b[i];

cout<<"Quick sort time and insertion sort time, with pivot middle element:"<<(t2 - t1)*1000/ ( CLOCKS_PER_SEC );

cout<<"\n";

t1=clock();

QuickSort(arr, 0, n-1,"Type4 sort");

t2=clock();

cout<<"Quick sort time and insertion sort time, with pivot median element:"<<(t2 - t1)*1000/ ( CLOCKS_PER_SEC );

return 0;

}

Explanation:

Change the value of n in the main file for different array size. Output is in the same format as mentioned, time is shown in milliseconds.

7 0
3 years ago
Write a recursive method named binarySearch that accepts a sorted array of integers and an integer target value and uses a recur
djyliett [7]

Answer:

10

-1

Process finished with exit code 0

Explanation: see code bellow

public class BinarySearchRecursive {

   public static int binarySearch(int[] a, int key) {

       return binarySearchRecursiveHelper(a, key, 0, a.length - 1);

   }

   public static int binarySearchRecursiveHelper(int[] arr, int target, int start, int end) {

       if (start > end) {

           return -1;

       }

       int mid = (start + end) / 2;

       if (arr[mid] == target) {

           return mid;

       } else if (target < arr[mid]) {

           return binarySearchRecursiveHelper(arr, target, start, mid - 1);

       } else {

           return binarySearchRecursiveHelper(arr, target, mid + 1, end);

       }

   }

   public static void main(String[] args) {

       int[] a = {-4, 2, 7, 10, 15, 20, 22, 25, 30, 36, 42, 50, 56, 68, 85, 92, 103};

       int index = binarySearch(a, 42);   // 10

       System.out.println(index);

       index = binarySearch(a, 66);   // -1

       System.out.println(index);

   }

}

6 0
2 years ago
In addition to avoidance and adaptation, two other means of risk reduction available to managers are ________ and ________. A. q
MrRissso [65]

Answer:

(b). dependency and hedging.

Explanation:

In the management of risk, four common approaches for reducing risk are;

i. <em>Avoidance</em>: Especially if a risk involved in the management of a resource (or project) poses or presents a negative consequence, the best way to manage the risk simply avoid it by making sure it doesn't happen. This can be by cancelling a project or restructuring it.

ii. <em>Adaptation</em>: Another way of managing the risk associated with a resource (human or non-human resource) is to control the risk either by increasing resilience or reducing vulnerability. This is called adaptation.

iii. <em>Dependency: </em>This means accepting the risk since every project or business has inherently in it some risk associated. Dealing with it might be a way out especially knowing that there might be some experience to be gained in order to tackle similar situation in the future.

iv. <em>Hedging: </em>This means transferring the risk to some other business or organization. An example might be to get an insurance to manage this risk. In this case, the risk is transferred to the insurance company.

7 0
2 years ago
Read 2 more answers
Other questions:
  • Your company is developing a new marketing campaign and wants to know which customers have never placed an order. You will need
    10·1 answer
  • Assume that an int variable age has been given a value. Assume further that the user has just been presented with the following
    14·1 answer
  • Which finger types the return or enter key?
    6·2 answers
  • Give an example of an app, website, or a game that used addictive design. Describe three features of addictive design it uses.
    11·2 answers
  • Which of the following is a scam in which a perpetrator sends an official looking e-mail that attempts to obtain a user’s person
    7·2 answers
  • Electronic mail is best used to:
    5·2 answers
  • One benefit proprietary licensed software is that it
    9·1 answer
  • Who invented computer ?​
    9·2 answers
  • When spraying pesticide wear and protective eyeglass​
    13·2 answers
  • Question 8 of 10
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!