answer.
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
Musya8 [376]
2 years ago
10

You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, an int variable nZips

that contains the number of elements in zipcodeList, and a bool variable duplicates. Write some code that assigns true to duplicates if any two elements in the array have the same value, and that assigns false to duplicates otherwise. Use only j, k, zipcodeList, nZips, and duplicates.
Computers and Technology
2 answers:
irina [24]2 years ago
5 0

Answer:

You cant use j =0… you have to use j = k+1, otherwise j =1 and k =1 will match up and be equal when really its comparing the exact same line to itself.

Explanation:

The solution will be as follows:

duplicates = false

for (k = 0; k < nZips; k++){

   for (j = k+ 1 ; j < nZips ; j++){

     if (zipcodeList [k] ==zipcodeList[j]){

          duplicates =true

           break;

              }

        }

}

dmitriy555 [2]2 years ago
3 0

Answer:

The c++ program for the scenario is given below.

#include <iostream>

using namespace std;

int main() {    

   int i,j, nZips, zipcodeList[nZips];

   bool duplicates;        

   cout<<"This program checks if duplicate values exist in the array." <<endl;    

   cout<<"Enter the number of integers to be inserted in the array."<<endl;

   cin>>nZips;    

   cout<<"Enter the integers to be inserted in the array."<<endl;    

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

   {

       cin>>zipcodeList[i];

   }    

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

   {

       for(j=0; j<nZips; j++)

       {

           if(i != j)

           {

               if(zipcodeList[i] == zipcodeList[j])

               {

                   duplicates = true;

                   cout<<"The value of duplicates variable is true meaning "<<duplicates<<endl;

                   break;

               }

               else

                   duplicates = false;

           }

       }

       

       if(duplicates == true)

               break;

}    

   if(duplicates == false)

       cout<<"The value of duplicates variable is false meaning "<<duplicates<<endl;    

   return 0;

}  

OUTPUT

This program checks if duplicate values exist in the array.

Enter the number of integers to be inserted in the array.

7

Enter the integers to be inserted in the array.

1234

2345

1234

5678

9087

6554

4560

3456

6789

The value of duplicates variable is true meaning 1  

Explanation:

The variables mentioned in the question are used as required. There is no logic applied to validate user input. It is assumed that user inputs only valid values.

This program is designed to check whether duplicate values are present in the array. The boolean variable duplicates is assigned value true or false depending on the presence of duplicate values.

The user is prompted the number of values to be put in the array along with those values.

Once the array is filled, the array is checked for identical values. If any identical value is present, the value of duplicates variable is assigned to true and the loop is discontinued.

If no identical values are present, the loop completes and duplicates variables is assigned the value of false.

In either case, the value of the duplicates variable is displayed.

You might be interested in
An online retailer is looking to implement an enterprise platform. Which component of the enterprise platform will help the comp
adelina 88 [10]

Answer: Data and Insights

Explanation:

Data and Insights in an enterprise platform is very important as it helps users better understand their customers so that they may be able to offer them the best services.

Data allows the platform to capture the data of the customer and insights then curates and consumes the data for analysis. The result of this analysis will enable the company to better understand the customer so that they might be able to offer preferable products.

3 0
1 year ago
Why are computer manufacturers constantly releasing faster computers? how do computer users benefit from the increased speed?
Anastaziya [24]
<span>As programs and online activities have grown more robust and innovative, it has simultaneously required computer manufacturers to identify ways to make their devices faster to keep up with these changes. Users benefit immensely due to their ability to have boundless and efficient access to their various needs.</span>
8 0
1 year ago
A large department store has been attaching tags with barcodes to merchandise, and employees use barcode readers to scan merchan
77julia77 [94]

The department store should consider using RFIDs (Radio Frequency Identification) for tracking inventory. Unlike the wireless barcodes, RFID uses radio waves to communicate with readers. One very common advantage of an RFID is the scanning range. Wireless barcodes, for instance, requires the reader to be close to the barcode before it can see it to scan it. However, RFID systems can scan a tag as long as it is within range. This is important because it reduces wastage of time on labor-intensive processes and increases task speed, convenience, and project turnover.

Many passive RFIDs use tags that are powered by electromagnetic energy. Such energy does not consume power.


8 0
1 year ago
Read 2 more answers
#Write a function called string_finder. string_finder should #take two parameters: a target string and a search string. #The fun
adoni [48]

Answer:

I am writing a Python program:

def string_finder(target,search): #function that takes two parameters i.e. target string and a search string

   position=(target.find(search))# returns lowest index of search if it is found in target string

   if position==0: # if value of position is 0 means lowers index

       return "Beginning" #the search string in the beginning of target string

   elif position== len(target) - len(search): #if position is equal to the difference between lengths of the target and search strings

       return "End" # returns end

   elif position > 0 and position < len(target) -1: #if value of position is greater than 0 and it is less than length of target -1

       return "Middle" #returns middle        

   else: #if none of above conditions is true return not found

       return "not found"

#you can add an elif condition instead of else for not found condition as:

#elif position==-1    

#returns "not found"

#tests the data for the following cases      

print(string_finder("Georgia Tech", "Georgia"))

print(string_finder("Georgia Tech", "gia"))

print(string_finder("Georgia Tech", "Tech"))

print(string_finder("Georgia Tech", "Idaho"))

Explanation:

The program can also be written in by using string methods.

def string_finder(target,search):  #method definition that takes target string and string to be searched

       if target.startswith(search):  #startswith() method scans the target string and checks if the (substring) search is present at the start of target string

           return "Beginning"  #if above condition it true return Beginning

       elif target.endswith(search):  #endswith() method scans the target string and checks if the (substring) search is present at the end of target string

           return "End" #if above elif condition it true return End

       elif target.find(search) != -1:  #find method returns -1 if the search string is not in target string so if find method does not return -1 then it means that the search string is within the target string and two above conditions evaluated to false so search string must be in the middle of target string

           return "Middle"  #if above elif condition it true return End

       else:  #if none of the above conditions is true then returns Not Found

           return "Not Found"

6 0
1 year ago
Exponentiation Is a/an operater?​
garik1379 [7]

Answer:

Yes it is

Hope this helps

5 0
1 year ago
Other questions:
  • On the Picture Tools Layout tab, you can preview results of the numerous styles, borders, effects, and layouts by _______ comman
    7·2 answers
  • Writing a program in a language such as c or java is known as _____ the program.
    10·1 answer
  • If you have long column labels with columns so wide that they affect the readability of a worksheet, you should first
    7·1 answer
  • Software code is tested, debugged, fixed, verified, and then:
    11·1 answer
  • Which of the following is true of information systems?
    15·1 answer
  • In this exercise, you will create a couple of helper methods for ArrayLists in a class called ArrayListMethods.
    10·1 answer
  • For any element in keysList with a value greater than 60, print the corresponding value in itemsList, followed by a semicolon (n
    14·2 answers
  • Write a program that calculates taxi fare at a rate of $1.50 per mile. Your pro-gram should interact with the user in this manne
    12·1 answer
  • What do you call the two parts of lift that go down a mine
    13·2 answers
  • The hostel in which you plan to spend the night tonight offers very interesting rates, as long as you do not arrive too late. Ho
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!