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
Travka [436]
2 years ago
15

Write a method named numUnique that accepts a sorted array of integers as a parameter and that returns the number of unique valu

es in the array. The array is guaranteed to be in sorted order, which means that duplicates will be grouped together. For example, if a variable called list stores the following values: int[] list
Computers and Technology
1 answer:
SVEN [57.7K]2 years ago
3 0

Answer:

The method in Java is as follows:

public static int numUnique(int list[]) {  

int unique = 1;  

for (int i = 1; i < list.length; i++) {  

 int j = 0;  

 for (j = 0; j < i; j++) {

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

   break;  

 }

 if (i == j)  

  unique++;  

}  

return unique;  

}  

Explanation:

This line defines the numUnique method

public static int numUnique(int list[]) {

This initializes the number of unique elements to 1

int unique = 1;  

This iterates through the list

for (int i = 1; i < list.length; i++) {

The following iteration checks for unique items

 int j = 0;  

<em>  for (j = 0; j < i; j++) { </em>

<em>   if (list[i] == list[j]) </em><em>If current element is unique, break the iteration</em><em> </em>

<em>    break;  </em>

<em>  } </em>

 if (i == j)  

  unique++;  

}

This returns the number of unique items in the list

return unique;  

}  

You might be interested in
How many answers do you need to be able to write messages on here??
Kipish [7]

1,000

Hope this helps!



~Courtney

3 0
3 years ago
Where can you access email accounts on your windows 7 computer in order to modify current accounts or create new ones?
Mademuasel [1]
I'll create new ones because just for me, its so hassle
8 0
3 years ago
This is the formula for the future worth of an investment over time with consistent additional monthly payments and a steady rat
stepladder [879]

Answer:

The code is given in C++ below

Explanation:

#include <iostream>

using namespace std;

int main()

{

float fv,pv,r,k,n,pmt,totalmoneyinvested;

pv=1000.00;

r=6/100;

k=12; //The value of k should be 12 for monthly installments

n=45;

pmt=250;

totalmoneyinvested=pv+(pmt*12*45); //The total money you invested

 

fv=pv*(1+r/k)*n*k+pmt*((1+r/k)*n*k-1)*(1+r/k)*r/k;

 

cout<<"Initial Investment:"<<" $"<<pv;

cout<<"\nRate Of Return:6%";

cout<<"\nLength of Time:"<<n<<"year";

cout<<"\nMonthly Payment:"<<" $"<<pmt;

cout<<"\nFinal Amount:"<<" $"<<fv;

cout<<"\nThe Money You Invested Is $"<<totalmoneyinvested<<" And The Final Amount Is $"<<fv;

return 0;

}

4 0
3 years ago
Which of the following tasks is the project manager least likely to be involved in?
user100 [1]

Answer:

i think its d sorry if i am wrong

3 0
3 years ago
Read 2 more answers
When the tv was created (year)
nikitadnepr [17]

Answer:

1927

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • 1.Characters archetypes are typical characters that represent universal patterns of human or human roles. (True or false)
    14·1 answer
  • How does microchip work
    12·1 answer
  • Fill in the blank
    13·2 answers
  • which option of the AutoCorrect tool enables you to add and delete words that do not follow abbreviation rules?
    10·2 answers
  • If after a run of arc consistency during the backtracking search we end up with the filtered domains of *all* of the not yet ass
    12·1 answer
  • A network technician is tasked with designing a firewall to improve security for an existing FTP server that is on the company n
    9·1 answer
  • What is the difference between = and == in terms of java..?
    6·2 answers
  • How will Artificial Intelligence change the way we do things? .......C-Claim:
    10·1 answer
  • Write Epic username plz
    6·1 answer
  • These brainly bots need to stop!!
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!