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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:43:11+00:00 2026-05-26T13:43:11+00:00

In all the other cases I could find, it was due to code not

  • 0

In all the other cases I could find, it was due to code not in a method or incorrect bracketing, however I have checked all these. My code is this;

import java.util.*; 
public class averages {
   public static void main(String[] args) 
   {
      //initializing
      double mean = 0;
      double deviation = 0;
      int i = 0;
      double dataset = new double[10];
      double sum = 0;
      double subdev = 0;
      double subsum = 0;
      double dev = 0;

      //getting the numbers
      for (i = 0; i <= 9 ; i++)
      {
         Scanner input = new Scanner(System.in);
         System.out.println("Enter a number");
         dataset[i] = input.nextDouble();
      }

      //calling the function to get 
      avgarray(dataset[]);
      System.out.println("Average is " + mean);
      devequasion(dataset[]);
      System.out.println("Deviation is " + subdev);
   }
   public static double avgarray(double[] arraydata)
   {
      sum = 0;
      for (i = 0; i <= 9 ; i++)
      {
         sum += arraydata[i];
      }
      mean = sum / 10;
      return mean;
   }

   public static double devequasion(double[] devdata)
   {
      subsum = 0;
      for (i = 0; i <= 9 ; i++)
      {
         subsum += devdata[i]*devdata[i];
      }
      dev = math.sqrt((sum - avgarray(devdata[]))/ 9.0);
      return dev;
   }
}

Everything looks correct, but the errors will not go away.

  • 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-05-26T13:43:12+00:00Added an answer on May 26, 2026 at 1:43 pm

    You have quite a few problems there, such as:

    • Your defininition of dataset is incorrect. You create a array of doubles then try to assign that to a single double.
    • You pass dataset[] rather than dataset.
    • You have variables in avgarray and devequasion that are used but not declared (mean, sum, subsum, i, dev). The fact that these are declared in main is not relevant.
    • Also, because they’re only used in the methods, they’re unnecessary in main, other that i of course).
    • You don’t import java.util.Scanner for the data input.
    • The math package is Math with a capital M.

    If you use an IDE like Eclipse, you will find it a lot easier to see and fix these problems. For beginners, that’s a ${DEITY}-send.

    By all means pump your code into javac as a final step if you have to (headless builds, compatibility and so forth) but do your initial development with an IDE, you’ll find it much faster.

    Here’s a version with all those syntactical problems rectified, and a few other minor tweaks, such as the removal of unnecessary variables:

    import java.util.Scanner;
    
    public class testprog {
        public static void main (String[] args) {
            double[] dataset = new double[10];
    
            for (int i = 0; i <= 9 ; i++) {
                Scanner input = new Scanner (System.in);
                System.out.println ("Enter a number: ");
                dataset[i] = input.nextDouble();
            }
    
            System.out.println ("Average is " + avgarray (dataset));
            System.out.println ("Deviation is " + devequasion (dataset));
        }
    
        public static double avgarray (double[] arraydata) {
            double sum = 0;
            for (int i = 0; i <= 9 ; i++)
                sum += arraydata[i];
            return sum / 10;
        }
    
        public static double devequasion (double[] devdata) {
            double subsum = 0;
            for (int i = 0; i <= 9 ; i++)
                subsum += devdata[i] * devdata[i];
            return Math.sqrt ((subsum - avgarray (devdata)) / 9.0);
        }
    }
    

    Don’t use this verbatim if it’s homework, you would be foolish to assume your educators were not actively searching the web for plagiarism.

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

Sidebar

Related Questions

I have a BasePage class which all other pages derive from: public class BasePage
I have a problem with IE. All other browsers work fine, but in IE
I currently have a issue with firefox, where all other browser behave in the
How to dim / fade all other windows of an application in Delphi 2009.
How can I display something over all other application. I want to to display
How do I print the indicated div (without manually disabling all other content on
I know that the live() event handles event bubbling different than all other jQuery
How can one ignore Unexpected element situation in JAXB ans still get all other
Actually in the center of current view, above all other objects. Cross-browser and without
An XSLT-newbie problem: I need to substitute a text value in XML-file. All other

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.