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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:26:17+00:00 2026-06-14T04:26:17+00:00

the program successfully compile and run. however, the value for the minimum score is

  • 0

the program successfully compile and run.
however, the value for the minimum score is wrong, i check again and cant figure out why
pls help me solve this

/* import neccessary component for the program*/
import java.util.*;

public class assign4 {

    /* create a input stream*/ 
    static Scanner console = new Scanner(System.in);

    public static void main(String[]args) {

        /* declare variables and strings*/
        int[] score;

        score = new int[10];
        String[] name;

        name = new String[10];
        String header = String.format("%10s%10s%8s%n", "Name", "Score", "Grade");
        int min = score[0];
        int max = score[0];
        char grade[];

        grade = new char[10]; 
        int maxindex = 0;
        int lowindex = 0;

        for (int i = 0; i <= 9; i++) {

            /* Get user's input for student's name and score*/   
            System.out.println("Please enter the student's name.");
            name[i] = console.nextLine();
            System.out.println("Please enter the student's score.( 0-100 )");
            score[i] = console.nextInt();

            if (score[i] > 80) {
                grade[i] = 'A';
            } else if (score[i] > 65) {
                grade[i] = 'B';
            } else if (score[i] > 40) {
                grade[i] = 'C';
            } else if (score[i] > 20) {
                grade[i] = 'D';
            } else {
                grade[i] = 'E';
            } 

            /* when the score is higher than the score, it become maximum score*/
            if (score[i] > max) {
                max = score[i];
                maxindex = i;
            } /* when the score is lower than the score, it become minimum score*/ else if (score[i]
                    < min) {
                min = score[i];
                lowindex = i;
            } /* when the score neither lower or higher than the score, it will be ignored and program         
             do nothing*/ else {} 

            /* avoid scanner skipping in order to capture user's input */
            console.nextLine();
        }

        /* print out the stored information of the students and show higest and lowest score */
        System.out.println();
        System.out.print(header);
        for (int i = 0; i <= 9; i++) {
            System.out.printf("%10s%10d%8s%n", name[i], score[i], grade[i]);
        } 
        System.out.printf("%s obtains lowest score of %d%n", name[lowindex], min);
        System.out.printf("%s obtains higest score of %d%n", name[maxindex], max); 

    }
} 

the program purpose is to collect 10 person score and name, then print out name, score, highest score, lowest score and grade.
Also, i just join this website, if the method i pose and asking is wrong, do tell and im sorry

  • 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-14T04:26:19+00:00Added an answer on June 14, 2026 at 4:26 am

    You initialize int min = score[0]; which will be 0, because score is an int[] with 0 as default value for every entry.

    You probably don’t get any scores below 0, so if(score[i]<min) will only be true for negative values. Try initializing min with Integer.MAX_VALUE.

    Also it’s good practice to initialize max with Integer.MIN_VALUE, but it shouldn’t matter in your case.

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

Sidebar

Related Questions

I am attempting to compile and run a C program in Xcode. This program
I successfully compile the program at the Question How to pass a string type
I am attempting to compile and run a test C program in Xcode. This
My program will not successfully compile in /MT (MultiThreaded) mode. It Compiles in /MD
I am getting this error when I run the program. It compiles successfully but
hi i have a cuda program which run successfully here is code for cuda
I successfully compiled the following program simple.cc: #include <gtkmm.h> int main (int argc, char
I have my program written in C++ and it is can be successfully compiled
I wrote my first program in Haskell today. It compiles and runs successfully .
Having successfully gotten a sample program working, I'm now starting to do Real Work

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.