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
castortr0y [4]
3 years ago
6

Assume that nextWord is a String variable that has been given a String value consisting entirely of letters. Write some Java cod

e that outputs the message "First half of the alphabet" , provided nextWord precedes "N" in alphabetic ordering. IfnextWord does not precede "N" in alphabetic ordering, the code should output"Second half of the alphabet" . (Note that "N"uses double quotes to produce aString value, as opposed to using single quotes to produce achar value.) '
Computers and Technology
1 answer:
wel3 years ago
8 0

Answer:

The code example is given below with explanation in c++ language.

Explanation:

Comments will explain what's going on in the code. Below code is already compiled and tested.

#include <time.h>

#include <iostream>

#include <sstream>

using namespace std;

int main(void)

{

//defining start and end time variable

// which will be used to break the infinte loop

   time_t endwait;

   time_t start = time(NULL);

   time_t seconds = 3; // end loop after this time has elapsed

cout<<"Input your number :";

long userNum;

cin>> userNum;

// initializing end time by adding seconds with start time

   endwait = start + seconds;

   // defining outputString which will concatenate all the  

   // divisible numbers in loop

string outputString="";

// bool isCompleted will use to check whether our  

// loop breaks successfully or time is expired.

bool isCompleted=true;

// iterate loop until it comes to 1. as in loop

// the program already displayed the 1 value.

   while (userNum>1)

   {  

  // checking start and end time comparison to  

  // break the infinite loop after some seconds

    if(start >= endwait){

     cout<< "Program end never reached.";

     isCompleted=false;

     break;

 }

 

    userNum=userNum/2;

   // defining stringstream to convert from long to string

    stringstream longToString;

    longToString<<userNum;

  // concatenating all the values

    outputString = outputString + longToString.str()+" ";

   // re initializing the start time with current time.

       start = time(NULL);

   }

   

  // check if while loop breaks successfully then print the

   // series of numbers here.

   if(isCompleted) {

    cout << outputString;

}

   return 0;

}

You might be interested in
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
What class of attacks use innovative attack tools and once a system is infected it silently extracts data over an extended perio
KatRina [158]

Answer:

Advanced persistent threat.

Explanation:

Advanced persistent threat is a threat actor implemented by either a government supported or private group to intrude a network or system and stays undetected, collecting information over a period of time.

It is used by cyber terrorist group to facilitate massive attacks based on the information retrieved. National or government group use the concept to promote national security.

7 0
3 years ago
How does microsoft label mac addresses in the windows utilities that show you the mac address?
statuscvo [17]

Based on computer analysis, Microsoft labels mac addresses in the windows utilities "<u>by showing the MAC address in the 'Physical Address' field."</u>

<h3>What is MAC Address?</h3>

MAC Address is the acronym for media access control address. A distinct identifier is allocated to a network interface controller (NIC).

MAC address is used as a network address in communications within a network component.

There are two ways to check for a MAC address in the Windows Utilities which is either through Command Prompt or Network Setting.

Hence, in this case, it is concluded that the correct answer is "<u>by showing the MAC address in the 'Physical Address' field."</u>

Learn more about MAC Address here: brainly.com/question/24812654

6 0
2 years ago
Is a procedure to copy one or more files from backup media to the original disk or a replacement disk when data or programs have
Stels [109]
Restore is a procedure to copy one or more files from backup media to the original disk or a replacement disk when data or programs have been erased or destroyed.
4 0
3 years ago
Concept tests in the screening and evaluation stage of the new-product process rely on written descriptions, sketches, or mock-u
pochemuha

Answer:

The answer is "Actual products".

Explanation:

The key purpose of this research is to better analyze the concepts, which is done to establish customer buying expectations and perceptions of the item. The key point is to assess the consumers ' initial response to the product idea.

  • This concept testing is also known as a creation, it is an advantage, which can be conveyed to the user to test their reactions.  
  • In conceptual testing, it is a quality check between the design definition and the actual production of the product.

6 0
3 years ago
Other questions:
  • What process describes using technology as a basis for controlling the access and usage of sensitive data?
    7·1 answer
  • Who invented the Graphical User Interface (GUI)?
    5·1 answer
  • Which function should be used to display a value based on a comparison?
    11·1 answer
  • Your mom wants to purchase a computer. She has heard about how the Windows 8 operating system is best-geared for a touch-enabled
    8·1 answer
  • Use the image above to determine which toolbars will be displayed in the program you are using. SELECT ALL THAT APPLY
    11·2 answers
  • Karen thinks she should go out with Blane, an unattractive, social misfit, because “If I don’t go out with him, people will thin
    7·1 answer
  • How does emotional awareness help you with non-verbal communication?
    13·2 answers
  • A10:A20 Refer to values in
    8·1 answer
  • How to identify mistakes in a html code??​
    14·1 answer
  • oe, a user, receives an email from a popular video streaming website. the email urges him to renew his membership. the message a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!