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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:33:00+00:00 2026-05-24T12:33:00+00:00

I have a task that requires me to print out the following quantities: I

  • 0

I have a task that requires me to print out the following quantities:

I need to write a java program that can calculate:
1. the number of integers read in
2. the average value—which need not be an integer!

My final output should look like:

$ javac SimpleCalc 
$ java SimpleCalc 3 4 6 8 1 
5
8
4.4 
7

I know i need to use a scanner class to read then as the user inputs then, i dont know how to make it display a count. I think that i can work this out, i can compute the average by adding up the numbers and divide the toal by the number of integers entered.

However its my first time writing a program, and this is doing my head in. Any help would be appreciated, ill even accept pseudocode if it helps me work out how to approach this.

  • 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-24T12:33:02+00:00Added an answer on May 24, 2026 at 12:33 pm

    Here you are supposed to use the arguments of the main function:

    public class PrintArgs {
        public static void main (String[] args) {
            for (int i = 0; i<args.length; ++i) {
              System.out.println("Args " + (i + 1) + " is " + args[i]);
            }
        }
    }
    

    Save this class in a file called PrintArgs.java and compile it using javac:

    $ javac PrintArgs.java
    

    Run the generated class file using java:

    $ java PrintArgs hello world
    Args 1 is hello
    Args 2 is world
    
    $ java PrintArgs 3 4 6 8 1 
    Args 1 is 3
    Args 2 is 4
    Args 3 is 6
    Args 4 is 8
    Args 5 is 1
    

    Now you know how to read input from the user. To convert a String to int, use the parseInt method of the Integer class:

    int i = Integer.parseInt("980");
    System.out.println(100 + i); // => 1080
    

    Now you know how to write your calculator program!

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

Sidebar

Related Questions

Hi and thanks for looking! Background I have a computing task that requires either
I have a task that requires me to delete all folders in a directory
I have a task that runs periodically 10 second. I do some picturebox refreshing
I have a task that takes a rather long time and should run in
I have a task that's driving me crazy because i have no clue where
Just stumbled upon propertyGrid and its awesome! However, i have one task that i
I have a periodic task that needs to execute once a minute (using delayed_job).
I have an MSBuild task that executes (among other things) a call to xcopy.
I have a scheduled task that is very IO intensive (deleting hundreds of thousands
I have a Fabric task that needs to access the settings of my Django

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.