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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:48:06+00:00 2026-06-05T22:48:06+00:00

A simple java program to input the name of student and find the average

  • 0

A simple java program to input the name of student and find the average of marks of three subjects obtained by him

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class MyException extends Exception
{

    MyException(String s)
    {
        super(s);
    }
}

class Student 
{
    String name;

    String inputName()
    {
        return name;
    }

    void average(int [] a)
    {
        int d;

        if ((a.length)==3)
        {
            d = (a[0]+a[1]+a[2])/3;
            if (d>50)
                System.out.println(" Congratulations!!! "+name+ " 
                        you have passed the examination");
            else
            System.out.println(" Oops  " +name+"  Try Later!!");
        }
    }

public static void main(String x[]) throws IOException
{
    Student s= new Student();
    int args[] =new int[3];
    System.out.println("Enter name of the student:");
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    s.name=br.readLine();
    System.out.println("Name of the student is " +s.inputName().trim());
    System.out.println("Marks in Physics = ");
    args[0]=Integer.parseInt(br.readLine().trim());
    System.out.println("Marks in Chemistry = ");
    args[1]=Integer.parseInt(br.readLine().trim());
    System.out.println("Marks in Mathematics = ");
    args[2]=Integer.parseInt(br.readLine().trim());**$$**
    s.average(args);**##**
}
}

The code has no errors.The code is executing till $$ step ,but the step indicated with ## is not executing.I don’t know why??

  • 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-05T22:48:08+00:00Added an answer on June 5, 2026 at 10:48 pm

    Following is the output of a test run:

    Enter name of the student:
    hello
    Name of the student is hello
    Marks in Physics = 
    52
    Marks in Chemistry = 
    52
    Marks in Mathematics = 
    52
     Congratulations!!! you have passed the examination
    

    So, the method is actually executing but the reason you are not seeing any output is, just like others have pointed out, the following condition is not satisfied

    if (d > 51)
    

    Also it would be nice to add else part as follows:

    if (d > 51)  {
        System.out.println("Congratulations!!! you have passed the examination");
    } else {
        System.out.println("Sorry!!! you have failed the examination");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Simple java program named MainController.java. Wehn I try to compile it from
I am trying to write a simple java program which returns me all the
I have been trying to call a mapreduce job from a simple java program
I was processing several txt files with a simple Java program, and the first
i found many related questions here. I have a simple java program . it
I want to create a simple bash script to launch a Java program on
I wrote a simple program in java web forms but i am receiving the
This is my simple program in Java: public class Counter extends Thread { public
I have a simple program (written in Java) which uses the google protocol buffer
I am writing a java program in eclipse(galileo version). The program reads simple user

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.