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 8223115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:33:41+00:00 2026-06-07T14:33:41+00:00

Basically I’m trying to make doubles work with integers and maybe I’m missing something

  • 0

Basically I’m trying to make doubles work with integers and maybe I’m missing something obvious, but, with the return highValue code, I’m getting an error that says, “Possible loss of precision, required: int, found: double”. As far as comments are concerned, it’s for a class I’m taking. Here’s the code:

package pj701;

public class PJ70103 {

     public static void main(String[] args)
    {   //DO NOT CHANGE ANYTHING IN THE MAIN()
        double[] x = { 11.11, 66.66, 88.88, 33.33, 55.55 };
        double[] y = { 9, 6, 5, 8, 3, 4, 7, 4, 6, 3, 8, 5, 7, 2 };
        double[] z = { 123, 400, 765, 102, 345, 678, 234, 789 };

        int index = FindIndexHighest (x);

        System.out.printf( "%s%5d%s%8.2f\n", "Array x:  element index = " ,  index,
                "  element contents = ", x[index] );

        index = FindIndexHighest (y);
        System.out.printf( "%s%5d%s%8.2f\n", "Array y:  element index = " ,  index,
                "  element contents = ", y[index] );

        System.out.printf( "%s%5d%s%8.2f\n", "Array z:  element index = ",
                 FindIndexHighest (z),  "  element contents = ",
                 z[FindIndexHighest (z) ] );
}
 //======================================================
// put your method definition here - - ONE method
//======================================================

     public static int FindIndexHighest(double[] x)
     {
        double highValue = 0;
        for (int i = 1; i < x.length; i++)
        {
            if (x[i] > highValue)
                    {
                        highValue = x[i];
                    }
            else
            {
                highValue = highValue + 0;
            }

        }
        return highValue;
     }
}
  • 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-07T14:33:43+00:00Added an answer on June 7, 2026 at 2:33 pm

    I think you need to check the requirements of the assignment again. It’s not the value that’s being asked for, but the index of this value in the passed array.

    As for the compiler warning, it means that when you try to implicitly cast a double into an int you may loose some of the information you had. E.g. double d = 3.5; int i = d; will result in i == 3, so the information after the decimal is lost. This is what the compiler is warning you about. To get rid of the warning, issue an explicit cast, e.g. int i = (int)d; in the above example.

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

Sidebar

Related Questions

Basically what I'm trying to do is make a very simple vertical bullet projectile
Basically, what I'm trying to create is a page of div tags, each has
Basically I am writing a simple bit of code to increment every one second
Basically i'd like to allow an arbitrary (but not empty ) number of key-value
Basically I have some simple code that does some things for files and I'm
Basically I'm trying to improve on the Ghosts in a Pacman game I'm making.
Basically my task is to make the counter on a micro controller board count
Basically i'm trying to build a comment system. The user looks at a photo
Basically, what I am trying to do is to find last section of PE
Basically i've a table for my users (it's nightclub website) and now i'm trying

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.