Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9260551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:55:20+00:00 2026-06-18T12:55:20+00:00

I am still learning Java and have a question on an array. My array:

  • 0

I am still learning Java and have a question on an array.

My array:

 double arr[] = {1.8, 3.6, 5.0, 2.0};

My question is how do I divide the first index by the next and so on, but not the last index.
Each index is to be divided by 2. So that the resulting array looks like this:

double arr[] = {0.5, 0.72, 2.5, 2.0};

I am on the right track by proceeding this way:

public static void main(String [] args){
    double arr[] = {1.8, 3.6, 5.0, 2.0};

    for(int j = 0; j < arr.length; j++){
        arr[j] = arr[0] / arr[1];
        arr[j] = arr[1] / arr[2];

        System.out.println(arr[j]);
    }
}

I am not sure how to proceed and all help is appreciated.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:55:21+00:00Added an answer on June 18, 2026 at 12:55 pm

    try this:

    for(int j = 0; j < arr.length-1; j++){
            arr[j] = arr[j] / arr[j+1];
            System.out.println(arr[j]);
        }
    System.out.println(arr[arr.length-1]);  // this will print the last element 
    

    `

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realise that this might be a stupid question, but I have not come
Apologies for the generic nature of this question. I have been learning Java for
Hello all my second question here so be gentle :) I'm still learning java
I have been learning Java for a while now and still learning new syntax
I'm still at the beginning in learning scala in addition to java and i
Still learning JSP Web Applications here. I have been doing this for a while
First of all, this is my code (just started learning java): Queue<String> qe =
Sorry for asking this question, but I searched all Java-related questions, but I got
I'm still learning Perl at the moment and have been trying to get a
Still learning the ropes with Groovy, this problem has tripped me up since last

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.