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
Pie
3 years ago
5

Write a method that returns the sum of all the elements of an array of ints that have an odd index.

Computers and Technology
1 answer:
wolverine [178]3 years ago
5 0

Answer:

import java.io.*;

import java.util.Scanner;

class Odd {

public static void main (String[] args) {

    Scanner ele=new Scanner(System.in);//creating a scanner object.

      int n,sum=0;//declaring n and sum and initializing sum with 0.

    n=ele.nextInt();//taking input of the n.

    int [] arr =new int[n];//declaring an array arr.

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

    {

        arr[i]=ele.nextInt();//taking input of the array.

    }

    for(int i=0;i<arr.length;i++)

    {

        if(i%2!=0)//adding to the if index is odd.

        {

            sum+=arr[i];

        }

    }

    System.out.println(sum);

}

}

Input:-

6

1 2 3 4 5 6

Output:-

12

Explanation:

First I have created an a scanner object ele. I have taken two integers n and sum, n for number of array elements and sum for calculating the sum of odd indexed elements hence initializing it with 0.Then I have created an array named arr.Then taking the input of the n and array elements.Then looping over the array and calculating the sum.

You might be interested in
Simple question: what is bandwidth?
katen-ka-za [31]
The maximum amount of data transmitted over an internet connection in a given amount of time
8 0
3 years ago
Read 2 more answers
While conducting an IS audit of a service provider for a government program involving confidential information, an IS auditor no
RSB [31]

Answer:

The answer is letter D

Explanation:

Periodic independent audit of the work delegated to the subcontractor.

Because this is the guideline to garantee accountability, good governance, and transparency. In adittion, to provide more assurance for the protecting confidentiality of the information.

5 0
3 years ago
Write the definition of a method printdottedline, which has no parameters and doesn't return anything. the method prints to stan
oksian1 [2.3K]
Void <span>printdottedline()
{
   printf(".....\n");
}

</span>void printdottedline()
{
   printf(".....\n");
}
8 0
3 years ago
Gina is a database user and her supervisor has asked her to generate a report from the structured database. Gina does not know h
const2013 [10]

Answer: C. Query builder

Explanation:

Based on the information given in the question, since Gina does not know how to write SQL commands and no forms have been created, the best option to generate the report is a query builder.

With the Query Builder, Gina can be able to search and also select and filter the database objects, while also creating relationships between the objects, and save queries despite not having any SQL knowledge.

4 0
3 years ago
Which computer is the fastest to process complex data?
Andreas93 [3]

Answer:

D. 2.6 GHz processor, 8 GB RAM, 1 TB hard drive

Explanation:

In Computer science, the processor speed of a computer can be defined as the number of cycles per seconds that the central processing unit (CPU) of a computer operates. The processor speed typically determines the number of information that a computer is able to execute per seconds. Therefore, the higher or faster the processor speed the faster the computer in processing complex data.

Generally, the processor speed of a computer is measured in megahertz (MHz) or gigahertz (GHz).

Additionally, Radom Access Memory (RAM) can be defined as the main memory of a computer system which allow users to store commands and data temporarily. RAM is measured in megabytes (MB) or gigabytes (GB).

Generally, the Radom Access Memory (RAM) is a volatile memory and as such can only retain data temporarily.

All software applications temporarily stores and retrieves data from a Radom Access Memory (RAM) in computer, this is to ensure that informations are quickly accessible, therefore it supports read and write of files.

Hence, the computer which is the fastest to process complex data is the 2.6 GHz processor, 8 GB RAM, 1 TB hard drive because of the higher processor speed and RAM size.

7 0
3 years ago
Other questions:
  • Which steps will complete adding the cells A45 to A55?
    8·1 answer
  • Assume the following rules of associativity and precedence for expressions:
    7·1 answer
  • URGENT!!! Which statement is true with regard to bitmap images?
    6·2 answers
  • Write a C program that creates two threads to run the Fibonacci and the Runner processes. Threads will indicate the start and th
    14·1 answer
  • Retype the statements, correcting the syntax errors.
    9·1 answer
  • While working a night job at a call center, Eric creates an app called EatOut, which can be used to place orders at restaurants,
    14·1 answer
  • In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: Str
    9·1 answer
  • Write a program that uses these bounds and bisection search (for more info check out the Wikipedia page on bisection search) to
    8·1 answer
  • Verify (valid or not valid) using resolution the following reasoning: "Every student in the SCIS is a CS student or an IT studen
    15·1 answer
  • Why is an array like a list? How do you identify and find elements in an array? Explain the purpose of a try-catch block and giv
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!