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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:12:39+00:00 2026-05-27T21:12:39+00:00

I am completely new to Java and have an assignment coming up; with the

  • 0

I am completely new to Java and have an assignment coming up; with the brief being the following:

A Swing interface.
The application must allow the user to enter some data and click a button.
The application must have an event handler to react to the click button event.
The application must perform some operation on the data entered.
The application must return the modified data to the user.

I was originally going to create an app that converted numbers to different units (eg. kgs to lbs) but found it very difficult, so have decided to go for an app which finds the average of a number of inputs.

This is the code i have for finding the average of a pre-defined array:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

    class FindAverageNumber extends JFrame {
        public static void main(String[] args){
            double numbers[] = new double[]{1,2,3,4,5,6,7,8,9,20};
            double average = 0;
            double cumulative = 0;
            for (int i=0; i<numbers.length; i++){
                double selected = numbers[i];
                cumulative = (cumulative + selected);
            }
            average = (cumulative / numbers.length);
            System.out.println("The average of the array is: "+average);
        }
    }

The code seems to function properly but, being new to Java, i don’t know how to take in these numbers from the user while also incorporating a swing interface (which i’m lost on). I’m assuming accepting an array is the best way to do this, with the user being presented with a textfield. I don’t know how to separate the inputs up into their own index in the array.

I’d appreciate any help; i realise i have a lot of basic questions.

  • 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-27T21:12:40+00:00Added an answer on May 27, 2026 at 9:12 pm

    If you have a text field, you’ll need to parse the input. You can use the String.split() method:

    For example, if you received the input as "1,2,3,4,5" you would call it like

    input.split(",");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am completely new to android, and pretty much a Java newb. I have
I am really new at Java. I have been trying to allow text selection
I am completely new to java, but I have urgent requirement to create a
Hi I am completely new to Java, so sorry if my question may sound
Just a warning: I'm completely new to Java and am trying to teach myself
I know something about Java but completely new to Enterprise Java. I'm trying my
Im completely new to Java web stuff, but here goes my question: 1) How
Disclaimer: I'm completely new to Java EE/EJB and all that, so bear with me.
It seems that to install Clojure in every new IDE, I have to completely
Please forgive me if any of this is wrong -I'm completely new to Java.

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.