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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:57:12+00:00 2026-06-07T12:57:12+00:00

My last step involves getting the integer percent of the sum. So if I

  • 0

My last step involves getting the integer percent of the sum.
So if I enter:
2
1
1
2
The output should be:
2, which is 33.333% of the sum.
1, which is 16.666% of the sum.
1, which is 16.666% of the sum.
2, which is 33.333% of the sum.

Since I am very new to arrays, I am extremely puzzled. I don’t understand how to get the percent since user can enter any amount of integers. If it was only 2 integers, just say 2 and 2, they each would be 50 percent

import java.util.Scanner;
   public class Integers {
   /* program 7-1*/
      public static void main(String[] args) 
      {
         Scanner keyboard = new Scanner(System.in);
         System.out.println("How many numbers will you enter?");
         int size = keyboard.nextInt();
         int[] entry = new int[size];

         System.out.println("Enter " + entry.length + " integers, one per line:");

         int sum = 0;
         for (int index = 0; index < entry.length; index++)
         {
            entry[index] = keyboard.nextInt();
            sum +=  size;
         }

         System.out.println("The sum is " + sum + "." + "\nThe numbers are:" );         
      }
   }
  • 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-07T12:57:14+00:00Added an answer on June 7, 2026 at 12:57 pm

    Now that you have all entries and the sum, you are almost there:

    • You need another loop to go over entries one at a time
    • To calculate percentage, multiply the entry by 100.0, and then divide by the sum. Note the dot zero at the end of 100.0 – it’s there on purpose
    • If you are on Java 5 or later, a very convenient way of printing out a number followed by percentage sign is printf. Note, however, that the percent sign % needs to be escaped.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a pretty complicated query, and I'm slipping at the very last step.
I'm a bit stuck on the last step of getting the solution to problem
The code compiles without too much complaint, but the last step fails with the
Last night I tried to put together something that I have had working since
In the last step of installing FFmpeg-PHP, I had to type sudo make install
Hi been wrestling this form and the last step (actually submitting) has me scratching
I've created a reporting application on Railo. The last step of this is to
Per step 3b of this Jetty guide for using Keytool and OpenSSL, last step
Here is my try to create banned words tool but in last step i'm
I want to copy binaries to stage server as the last step of build.

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.