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

  • Home
  • SEARCH
  • 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 8928827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:32:12+00:00 2026-06-15T08:32:12+00:00

Hi guys basically im new to Java started in oct, im doing ComScience. I

  • 0

Hi guys basically im new to Java started in oct, im doing ComScience. I need help please with the following would be greatly appreciated.

NOTE: I have not really laid the code out yet so to speak i wanted to get the program to work first before structuring/comments etc . UULIB is name of the University librays.

OBJECTIVE: Find the NAME of students who have below AVERAGE mark.

This is the code i used below to try and find it but it skips the first [0] array number and gives me one name only.

import uulib.*;

public class Q3
{
    public static void main(String[] args)
    {
        int class_number = Console.getInt("Enter how many students between 1-10");

        while (class_number < 1 || class_number > 10)
            class_number = Console.getInt("Enter how many students between 1-10");

        System.out.println("");

        String[] name = new String[class_number];
        int[] score = new int[name.length];

        for (int i=0; i<class_number; i=i+1)
        {
            name[i] = Console.getString("Enter Name");
            score[i] = Console.getInt("Enter score");

            if ( score[i] < average(score))
                System.out.print(name[i] + " ");
        }

        System.out.println(" ");
        System.out.println("Average mark = " + Num.format(average(score), 1 ));
        System.out.println("Lowset mark = " +lowset(score) );
        System.out.println("Highest mark = " +highestValue(score) );
        System.out.println("Name of students with highest mark =  " );
    }

    public static double average(int[] nums)
    {
        double total = 0;

        for (int i=0; i<nums.length; i=i+1)
        {
            total = total + nums[i];
        }
        return total / nums.length;
    }

    public static int lowset(int[] nums)
    {
        int minimum = nums[0]; //sets the first to be the smallest

        for (int i = 0; i < nums.length; i++) //goes through your array
        {
             if (nums[i] < minimum) //checks and replaces if necessary
             {
                 minimum = nums[i];   
             }
        }
        return minimum;
    }

    private static int highestValue(int[] numbers) 
    {
        int highest = numbers[0];
        for (int i = 0; i < numbers.length; i++) 
        {
            if (numbers[i] > highest) 
            {
                highest = numbers[i];
            }
        }
        return highest;
    }
}
  • 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-15T08:32:12+00:00Added an answer on June 15, 2026 at 8:32 am

    You should split your for-loop into two for-loops as you can’t compute the average before having collected all scores:

    for (int i=0; i<class_number; i=i+1) {
        name[i] = Console.getString("Enter Name");
        score[i] = Console.getInt("Enter score");
    }
    for (int i=0; i < class_number; i++) {
        if (score[i] < average(score))
            System.out.print(name[i] + " ");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey Guys, having an issue with Linq-to-SQL, I am basically doing the following but
hey guys i need help configuring some source code to basically when a error
Hey Guys I would very much appreciate some help with the following. We're using
Hey guys was hoping you could help me out. basically i'm working on a
Having another tough one here guys, basically I would like to check if a
Guys would it be difficult to write coutn which would basically place newline symbol
Alright guys, Need some help! Im working with asp.net mvc3 razor (and am fairly
Guys I'm new to JavaScript, so not sure where the error is. Basically I've
I am entering a realm that is new to me, but basically I need
I need help converting this code from C# to Java. public static ulong GetChecksum(byte[]

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.