Write a method named lastIndexOf that accepts an array of integers and an * integer value as its parameters and returns the last index at which the * value occurs in the array. The method should return -1 if the value is not * found.

Answers

Answer 1

Answer:

The method is as follows:

public static int lastIndexOf(int [] numbers, int num){

    int lastIndex = numbers[0];

    for(int i =0; i<numbers.length;i+=num){

        lastIndex = numbers[i];

    }

    return lastIndex;

}

Explanation:

This defines the method

public static int lastIndexOf(int [] numbers, int num){

This initializes the lastIndex to the first element of the array

    int lastIndex = numbers[0];

This iterates through every "num" element of the array

    for(int i =0; i<numbers.length;i+=num){

This gets the current index... until the last

        lastIndex = numbers[i];     }

This returns the last

    return lastIndex; }


Related Questions

Write a program that uses input to prompt a user for their name and then welcomes them. Note that input will pop up a dialog box. Enter Sarah in the pop-up box when you are prompted so your output will match the desired output.

Answers

user_name = str (input = ("Please enter your name: "))

def greet (user_name):

print ("Welcome to your ghetto, {0}!".format(user_name) )

A sinewave has a period (duration of one cycle) of 645 μs. What is the corresponding frequency of this sinewave, in kHz, expressed to 3 significant figures?


please help me figure this out I am so confused

Answers

The corresponding frequency of this sinewave, in kHz, expressed to 3 significant figures is: 155 kHz.

Given the following data:

Period = 645 μs

Note: μs represents microseconds.

Conversion:

1 μs = [tex]1[/tex] × [tex]10^{-6}[/tex] seconds

645 μs = [tex]645[/tex] × [tex]10^{-6}[/tex] seconds

To find corresponding frequency of this sinewave, in kHz;

Mathematically, the frequency of a waveform is calculated by using the formula;

[tex]Frequency = \frac{1}{Period}[/tex]

Substituting the value into the formula, we have;

[tex]Frequency = \frac{1}{645\; * \;10^{-6}}[/tex]

Frequency = 1550.39 Hz

Next, we would convert the value of frequency in hertz (Hz) to Kilohertz (kHz);

Conversion:

1 hertz = 0.001 kilohertz

1550.3876 hertz = X kilohertz

Cross-multiplying, we have;

X = [tex]0.001[/tex] × [tex]1550.39[/tex]

X = 155039 kHz

To 3 significant figures;

Frequency = 155 kHz

Find more information: https://brainly.com/question/23460034

Mary has been locked out of her account after failing to correctly enter her password three times. As the system administrator, you need to unlock her account. Which of the following commands would unlock Mary's account assuming that you are using pam_faillock.so module?

a. faillock --reset --user mary
b. pam_faillock --unlock --user mary
c. pam_faillock --reset --user mary
d. faillock --unlock --user mary

Answers

Oh hey lol yea yea lol I got the money back to me put on the phone so you know

9. If you want to change the Header text of any Form then which property will you use
a) Header b) Text c) Name d) Font

Answers

Answer:

header

Explanation:

i would use header

what are the different versions of Ms word?​

Answers

Answer:

ms paint will not attend as the ICRC is the time to move becuse to get free skin on your skin that you have a doubt about the quality and

can somebody help what's wrong with this code
asap~

Answers

Answer:

There's a + missing to concatenate your variable to your string.

How do computer users benefit from the increased speed?

Answers

Answer:

jrjhfn4

Explanation:

jejehrurjrbrr

Pleaseeeeee helppppp meeeeeeee
Tomorrow is my examination.​
Please don't ignore.

Answers

Answer:

Floppy disk

Pendrive

sd card

CD

Router

Explanation:

Hope it is helpful

what is the difference between packed and unpacked bcd numbers ​

Answers

Explanation:

Packed BCD ( Binary coded decimal) is type in which each decimal digit is represented by 4 bits ( 1 nibble) . For Example : 14 will be shown as 0001 0100 in packed BCD form. Unpacked BCD is type in which each decimal digit is represented by 8 bits ( 1 byte).

8. Which clause will always executes
a) try b) catch c) finally d) None of them

Answers

Answer:

I think a is correct answer

If i took my SIM card out of my phone and put it in a router then connect the router and my phone with Ethernet cable would the ping change???

Answers

Answer:

ummmmmmmmmmmmm nooooo???

Create a Python dictionary that returns a list of values for each key. The key can be whatever type you want.

Design the dictionary so that it could be useful for something meaningful to you. Create at least three different items in it. Invent the dictionary yourself. Do not copy the design or items from some other source.

Next consider the invert_dict function.

def invert_dict(d):
inverse = dict()
for key in d:
val = d[key]
if val not in inverse:
inverse[val] = [key]
else:
inverse[val].append(key)
return inverse

Modify this function so that it can invert your dictionary. In particular, the function will need to turn each of the list items into separate keys in the inverted dictionary.
Run your modified invert_dict function on your dictionary. Print the original dictionary and the inverted one.
Describe what is useful about your dictionary. Then describe whether the inverted dictionary is useful or meaningful, and why.

Answers

Answer:

Explanation:

# name : [animal type, age, sex]

animal_shellter = {

 "Teddy": ["dog",4,"male"],

 "Elvis": ["dog",1,"male"],

 "Sheyla": ["dog",5,"female"],

 "Topic": ["hamster",3,"male"],

 "Kuzya": ["cat",10,"male"],

 "Misi": ["cat",8,"female"],

}

print(animal_shellter)

print("")

def invert(d):

 inverse = dict()

 for key in d:

   val = d[key]

   for item in val:

     if item not in inverse:

       inverse[item] = [key]

     else:

       inverse[item].append(key)

 return inverse  

inverted_shellter = invert(animal_shellter)

print(inverted_shellter)

Many Java programs that you create will receive and process user input. In order to ensure that user input is accurate, you will need to use input validation and exception handling.

a. True
b. False

Answers

Answer: True

Explanation: True

The speed of a computer is measured in____?​

Answers

Answer:

gigahertz

Explanation:

The clock speed measures the number of cycles your CPU executes per second, measured in GHz (gigahertz)

[tex]\sf{}[/tex]

ANSWER => gigahitrz

Explanation:

The speed of a computer is measured in gigahitrz

Write equivalent predicate statement for Every teacher who is also a painter loves Bob​

Answers

Answer:

Every teacher who is also a painter loves Bob

I have no idea how to answer this question so I’m just gonna

What is wrong with the following if statement (there are at least 3 errors).
The Indentation indicates the desired behavior.

if numNeighbors >= 3 || numNeighbors = 4
++numNeighbors;
printf ("You are dead! \n “);
else
--numNeighbors;

Answers

In programming, if statements are used to test conditions. The statement to be executed will be determined by the result of the conditions. A statement will be executed if its accompanying condition is true.

The errors in the given code segment are as follows:

The if condition on line 1 should be in a closed bracket; i.e. ()The if condition has more than 1 statements to execute. So, it requires a curly bracket; i.e. {}The second part of the first condition should be == 4 and not =4; because the proper operator to make comparison is == while = is used as an assignment operator

The correct code is as follows:

if (numNeighbors >= 3 || numNeighbors == 4) {

++numNeighbors;

printf ("You are dead! \n “); }

else

--numNeighbors;

Read more about conditional statements at:

https://brainly.com/question/20228453

Select the true statement about the motherboard.


It executes the commands sent to it by the application software.


It acts as a storage point for read-only memory (ROM).


It acts as the working memory of the computer by transferring data from the hard disk for processing.


It provides much of the electrical connection between different computer parts.

Answers

Answer:

it executes the commands sent to it by the applica software .

The motherboard provides much of the electrical connection between different computer parts.

What is a motherboard?

This is known to be a kind of  printed circuit board that is made up of some key parts or aspect of a computer or any kind of device.

Conclusively, it is one that is made up of It connectors that is a place where other circuit boards can be placed and as such act to provides much of the electrical connection between different computer parts.

Learn more about motherboard from

https://brainly.com/question/12795887

#SPJ2

Identify the statement about Windows tasks that is FALSE.


To launch an application, click the Windows icon, select "All Programs," and then click an application.


The boot process is the process for powering off a computer.


A common way to shut down the computer’s operating system is by using the Start menu.


Users log into their accounts on the Welcome screen, before Windows is ready to use.

Answers

The statement about Windows tasks that is FALSE is

The boot process is the process for powering off a computer.

According to the question, we are to discuss about Windows tasks and how it works as regards to the computer.

As a result of this we can see that  in launching an application;

we need to click on Windows iconselect "All Programs," click an application.

Therefore, The boot process is not the process for powering off a computer.

Learn more about Windows tasks .

https://brainly.com/question/1594289

The statement that is false is: The boot process is the process for powering off a computer, which is the second option. The boot process is actually the process of starting or powering on a computer, not powering it off.

The boot process refers to the sequence of events that occur when a computer is powered on or restarted. It is the process of starting up the computer's hardware and loading the operating system into memory so that it is ready for use. During the boot process, the computer's firmware (such as the BIOS or UEFI) performs a series of checks and tests to ensure that the hardware components are functioning correctly. It then searches for the operating system on connected storage devices, such as the hard drive or solid-state drive, and loads it into memory.

Learn more about the boot process here.

https://brainly.com/question/24355262

#SPJ6

2) What are three categories of computer languages? 3) Write four components of a QBASIC window. 4) What are the three types of operators in QBASIC? 5) What is the use of connector symbol in flowchart? 6) What is a computer network? 7) State two uses of Internet. 8) Write three examples for web browser. 9) Name some popular ISPs in Sri Lanka. 10) Differentiate between MAN and PAN.​

Answers

Answer:

2: assembly language , machine language and high level language

3: a character set , constants , variables , statements , operators and expressions

I really need To know how To get The special ending for final fight 2 for super nintendo it’s a video game

Answers

Answer:

Check Yt

Explanation:

More often than not there are many video tutorials about every game imaginable.

help me
Q3/ Put True or false in front of the following


statements:
1- You can use the Goal seek feature available by clicking on the data what-if analysis-> Goal Seek.
2- The equations in matrix form [X]-[A] [b]. 3- The A B matrix will be 2 3 ,where A is 2*3 and B is 3*3..
4- The command of inverse is +minverse(arry1...arry2).
5- The (By Changing Cells) box should contain the location of the decision variables for the problem.​

Answers

Answer:

TrueFalseFalseTrueFalse

Explanation:

mark me as brainlyest

is there similarities between plagiarism and software piracy? explain.​

Answers

PlagiarismPlagiarism means using someone else's ideas or words without crediting source.PiracyPiracy is unauthorized use, reproduction, or sharing of copyrighted material.

Select all steps in the list below that should be completed when using the problem-solving process discussed in this chapter.


Take action.

Take a break.

Evaluate.

Complete the task.

Consider solutions and list ideas.

Understand the task or need.

Ask a coworker for help.

Answers

Take action.

Evaluate.

Complete the task.

Consider solutions and list ideas.

Understand the task or need.

List any four strategies of IT Policy?

Answers

Answer:

News skill and qualifications

who is the owner of apple company??​

Answers

Answer:

Steven Paul Jobs......

....

Which best describes sorting, filtering, and deleting records?
O Sorting and filtering can be undone, but deleting records is a permanent change.
O Sorting can be undone, but filtering and deleting records are permanent changes.
O Deleting and filtering can be undone, but sorting records is a permanent change.
O Deleting can be undone, but sorting and filtering records are permanent changes.​

Answers

Answer:

Deleting and filtering can be undone, but sorting records is a permanent change.

Write a job back with my best Interest

Answers

Answer:

be a doctor

Explanation:

u will help people and save them and get paid

what is the role of output device?​

Answers

Answer:

The role of output device is to give the processed information in the form of result.

what do you mean by hardware and software?

Answers

Answer:

I think the above information will help you a lot.

Have a nice day.

Please read the screen shot brainly is not letting me write the whole thing

Consider a network that is a rooted tree, with the root as its source, the leaves as its sinks, and all the edges directed along the paths from the root to the leaves. Design an efficient algorithm for finding a maximum flow in such a network. What is the time efficiency of your algorithm

Answers

Answer:

please mark me brainlist

Explanation:

Other Questions
List 3 similarities of a virus and bacteria and give evidence from the text If I Have 100 Dollars And i go to the bank and i ask for 30 more and use that money on a store and i have 12 Dollars Left How Much Did the Thing I Bought Cost/ How Much Money did i spend? Which is an example of the study of physics and the human body?A. determining the optimum resting heart rateB. testing the impact of a car crash on the bodyC. calculating how to beat an existing sports recordD. training warehouse workers on how to properly move boxes the area of a parallelogram is 48cm.if the two adjacent sides are 8cm and 6cm, find the length of its diagonal . What are the effect caused due to conflict ? True or false? The smaller the temperature differences, the stronger the wind will be. 4 analytic indicators of globalizations effect and pick one country to examine with each indicator Can someone please fastly tell me in 5 reasons why is stephen hawking successful?. why is tolerating cheating bad? Which action demonstrates effective communication? Match the vocabulary word to its correct definition.1. mean The mean is the average value of the data you collect. In statistics, you find the mean of your sample. Then you use that mean to approximate the mean of the entire population. If you want the mean of the data to be a good approximation of the mean of the entire population, your need to make sure that you collect a random sample. To find the mean, you find the sum of the data points you collected and divide it by the number of data points in the set. For example, if the data you collected was {3, 3, 6}. Then the mean would be (3 + 3 + 6) 3 = 12 3 = 4. It's important to note that the mean does not have to be a data point in your set. You can generalize the formula as well. If you collect n data points {d1, d2, d3, dn}, then the mean of your data set is . The Greek letter pronounced "mu"is used because the word "mean" begins with the letter "m." It is important that you divide by the number of data points in your set, n. 2. population An experiment is a well-defined procedure under controlled conditions designed to gather data that tests a hypothesis. For example, you want to test the hypothesis that flowers grow faster when they are watered every other day as opposed to every day. Then you could water one set of plants every day and another set of plants every other day. What data would you collect? The height of each plant once a day. What conditions would you need to control? You would need to make sure that the groups of plants are treated the same in every other way by getting the same amount of sun and being maintained at the same temperature, etc. 3. experiment Bias is the preference for a particular group or subset. In the example above, the bias was toward viewers who like sports. When your sample is not chosen at random, you introduce bias into your study. So, in a certain sense, a biased sample is the opposite of a random sample. Why? In a biased sample, some members of the population are more likely to be chosen than others. In a random sample, every member of the population is equally likely to be chosen. Bias may also occur in surveys. See "survey" below for more information on this type of bias. 4. sample A population is the entire group you want to understand. So, in a certain sense, you can think of the population as the "opposite" of the sample because a sample is not the entire population. A sample is chosen subset upon that you use to draw conclusions about the entire population. 5. bias Random means free from bias. So, if you choose a random sample from a population, every member of the population has an equal chance of being chosen. It should be pointed out that this "true randomness" is an ideal which is difficult to achieve in real world experiments conducted on real world populations. That is why statisticians make every effort to ensure their samples chosen as free from bias as is possible, that is, as randomly as possible under real world conditions. 6. survey A sample is a subset chosen from a population. In most cases, you want a random sample. Why? A random sample has the best chance of accurately representing the entire population. 7. random A survey is the means of collecting a sample. In statistics, a survey is often a question or set of questions. It is critical that the questions, like the sample itself, be free from bias. Bias in a question tends to favor one response. As an extreme example of a biased question about colors might be, "Don't you think blue is beautiful and yellow is yucky?" An unbiased form of the question might be, "Which color do you prefer, blue or yellow?" Though careful, statisticians might be concerned about the order in which the colors are offered, so that might further simplify the question to, "What is your favorite color?" This type of question is most free from bias because it does not suggest a response and therefore does not favor a response. A ball is kicked from the ground. At 1 second it is 3 m off the ground. At 2 seconds it is 12 m off the ground, at 3 seconds it is 27 m off the ground After 3 bounces, how high is the ball TRIGONOMETRY Could someone please help me with 5.2 please...it would really help alot:) Let f(x) = 12/4x+2 Find f(-1). (1 point) our traditional knowledge skills and Technology can be seen more in the rural areas of our country. explain with suitable reasons. how many Georgia governors were members of the Republican Party during the 20th century? I really need To know how To get The special ending for final fight 2 for super nintendo its a video game The kinetic energy of a particle of mass 500g is 4.8j. Determine the velocity of the particle Read these stage directions from Eugene O'Neill's play The Straw.Act OneScene One: The Kitchen of the Carmody Home--Evening.Scene Two: The Reception Room of the Infirmary, Hill FarmSanatorium--An Evening a Week Later.Act TwoScene One: Assembly Room of the Main Building at the Sanatorium--A Morning Four Months Later.Scene Two: A Crossroads Near the Sanatorium--Midnight of the Same Day.Act ThreeAn Isolation Room and Porch at the Sanatorium--An Afternoon Four Months Later.TIME--1910Which of these can be determined from these scene descriptions?There are two scenes in each Act.The play takes place over the course of four months.One of the Carmodys' children is sick.Much of the action of the play takes place at a Sanatorium. Please help me anyone ????????!!!