last question

last question

  1. Input the name and marks of 25 students and compute the average. Print out the name and average of each student. (You can do this using an array or without using an array)
View Answers

December 29, 2011 at 12:19 PM

import java.util.*;
class Student{
    String name;
    int marks1;
    int marks2;
    int marks3;
    int average;
    Student(String name,int marks1,int marks2,int marks3,int average){
    this.name=name;
    this.marks1=marks1;
    this.marks2=marks2;
    this.marks3=marks2;
    this.average=average;
    }
    public String getName(){
        return name;
    }
    public int getMarks1(){
        return marks1;
    }
    public int getMarks2(){
        return marks2;
    }
    public int getMarks3(){
        return marks3;
    }
    public int getAverage(){
        return average;
    }
}
class StudentEx 
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        ArrayList<Student> list=new ArrayList<Student>();
        for(int i=0;i<25;i++){
            System.out.print("Enter Name: ");
            String name=input.next();
            System.out.print("Enter Marks1: ");
            int m1=input.nextInt();
            System.out.print("Enter Marks2: ");
            int m2=input.nextInt();
            System.out.print("Enter Marks3: ");
            int m3=input.nextInt();
            int total=m1+m2+m3;
            int av=total/3;
            list.add(new Student(name,m1,m2,m3,av));
        }
        for(Student st:list){
            System.out.println(st.getName()+"\t"+st.getAverage());
        }
    }
}









Related Tutorials/Questions & Answers:
last question
last question   Input the name and marks of 25 students and compute the average. Print out the name and average of each student. (You can do this using an array or without using an array
Clarify my last question's answer - Java Beginners
Clarify my last question's answer  Dear expert, I've tried out... did not specify my question too clearly. Here's my 2 database... question. Do you want to search through id or through the qualification selected
Advertisements
How to bookmark and preview last question in a java test engine - Java Beginners
How to bookmark and preview last question in a java test engine  Am creating a test engine with java, how can i generate questions randomly, allow a user bookmark a question view previous question and review questions
How to bookmark and preview last question in a java test engine - Java Beginners
How to bookmark and preview last question in a java test engine  Am creating a test engine with java, how can i generate questions randomly, allow a user bookmark a question view previous question and review questions
Further advice needed on my last question - JSP-Servlet
Further advice needed on my last question  Dear Experts, I refer to your last solution regarding my matching codes. After I tried out your solution, I get alot of errors.. .Netbean IDE mpiling 1 source file to C
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
Question
Question   When there is an exception in my program how java runtime system handles
question
question  dear sir/madam my question is how to compare two text format in java..we are java beginners..so we need the complete source code for above mentioned question...we have to compare each and every word
question
question  Dear sir i had some typing mistake at previous question so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory
question
could get the last results only from resultset,please correct this how to set
question
Last Name:"); l4=new JLabel("Employee Address:"); l5=new JLabel...:"); l16=new JLabel("Employee First Name:"); l17=new JLabel("Employee Last Name...=new JLabel("Employee Last Name:"); l30=new JLabe
question
question  Gud morning sir, I have asked u some question regarding jsp in saturaday for that i didnot find any answere in which u send me the some of the links.U have asked me the specify some details. There is a entity name
Question?
Question?  My question is how to: Add a menu bar to the program with a File menu. In the File menu, add a submenu (JMenuItem) called About. When the user clicks on the About menu item, display a JOptionPane message dialog
php remove last character
php remove last character  to remove the last character, i used the trim function which is not working
Last modified time of a webpage
Last modified time of a webpage  how can we get the last modified time of a webpage using java
Last modified date of a folder
Last modified date of a folder  How to get the last modified date of a folder specified by a link in html
php show last query
php show last query  How to show the last updated record from the database in PHP? Is there any query that i need to write in the php script
Transaction in last 3 months
Transaction in last 3 months  I have a project in which i have to calculate amount submitted through transactions in last three months. I have to check the date of all transactions in past 90 days and add the total amount
Mysql last day of month
Mysql last day of month       Mysql Last Day of Month is useful to provide you the last... illustrate an example from Mysql Last Day of Month. To understand
Find out last character of array
Find out last character of array  How we can find out the last character of array in java program
Mysql last day of month
Mysql last day of month       The Tutorial illustrate an example from 'Mysql Last Day of Month'. To  understand and grasp the example we run LAST_DAY
Mysql Last
Mysql Last       Mysql Last is used TO limit Mysql query result that fall in a specified range... results. The syntax to show the last records is pharsed as Limit X,Y. The X stands
ModuleNotFoundError: No module named 'last-model'
ModuleNotFoundError: No module named 'last-model'  Hi, My Python... 'last-model' How to remove the ModuleNotFoundError: No module named 'last... have to install padas library. You can install last-model python
ModuleNotFoundError: No module named 'last-shout'
ModuleNotFoundError: No module named 'last-shout'  Hi, My Python... 'last-shout' How to remove the ModuleNotFoundError: No module named 'last... have to install padas library. You can install last-shout python
ModuleNotFoundError: No module named 'pyxmpp-last'
ModuleNotFoundError: No module named 'pyxmpp-last'  Hi, My Python... 'pyxmpp-last' How to remove the ModuleNotFoundError: No module named 'pyxmpp-last' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'xp-last'
ModuleNotFoundError: No module named 'xp-last'  Hi, My Python...-last' How to remove the ModuleNotFoundError: No module named 'xp-last... to install padas library. You can install xp-last python with following command
ModuleNotFoundError: No module named 'xp-last'
ModuleNotFoundError: No module named 'xp-last'  Hi, My Python...-last' How to remove the ModuleNotFoundError: No module named 'xp-last... to install padas library. You can install xp-last python with following command
Mysql Last Record
Mysql Last Record       Mysql Last Record is used to return the last records from table... The Tutorial illustrate an example from 'Mysql Last Record'. To understand example we
JDBC ResultSet last() Example
JDBC ResultSet last() Example: The ResultSet last() are use to moves the cursor to the last row in the ResultSet object. It return true if the cursor pointed last row in the ResultSet and return false if the ResultSet object does
Mysql last row
Mysql last row       Query to Create Table named employee1:- mysql>CREATE TABLE...) Query to view last row of Table named employee1:- mysql>
return the position of last occurrence of an element
return the position of last occurrence of an element  A method " findLast(E element) " returns the position of the last occurrence of the given element. If this element is not in the list, then the null reference should
return the position of last occurrence of an element
return the position of last occurrence of an element  A method " findLast(E element) " returns the position of the last occurrence of the given element. If this element is not in the list, then the null reference should
How long will data Science last?
How long will data Science last?  Hi, I am beginner in Data Science... long will data Science last? Try to provide me good examples or tutorials links so that I can learn the topic "How long will data Science last?"
To Display the 'Last Modified' message in JSP
To Display the 'Last Modified' message in JSP  I have to display the "Last Modified" auto save message in a portlet page at the right end corner..."); var time = new Date(); element.innerHTML="Last Saved
Mysql Last
Mysql Last       Mysql Last is used TO limit Mysql query result that fall in a specified... from X-Y results. The syntax to show the last records is pharsed as Limit X,Y
Finding Last Modification Date of a file
Get the Last Modification Date      Get the Last Modification Date This section contains the detail about how to get the last modification date of a file
Question on pooling
Question on pooling  which server supports pooling?Application server or web server
ModuleNotFoundError: No module named 'django-last-modified'
ModuleNotFoundError: No module named 'django-last-modified'  Hi...: No module named 'django-last-modified' How to remove the ModuleNotFoundError: No module named 'django-last-modified' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-last-seen'
ModuleNotFoundError: No module named 'django-last-seen'  Hi, My... named 'django-last-seen' How to remove the ModuleNotFoundError: No module named 'django-last-seen' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-last-seen'
ModuleNotFoundError: No module named 'django-last-seen'  Hi, My... named 'django-last-seen' How to remove the ModuleNotFoundError: No module named 'django-last-seen' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-last-social-activity'
ModuleNotFoundError: No module named 'django-last-social-activity'  ...: No module named 'django-last-social-activity' How to remove the ModuleNotFoundError: No module named 'django-last-social-activity' error? Thanks
ModuleNotFoundError: No module named 'django-last-social-activity'
ModuleNotFoundError: No module named 'django-last-social-activity'  ...: No module named 'django-last-social-activity' How to remove the ModuleNotFoundError: No module named 'django-last-social-activity' error? Thanks
ModuleNotFoundError: No module named 'django-last-used'
ModuleNotFoundError: No module named 'django-last-used'  Hi, My... named 'django-last-used' How to remove the ModuleNotFoundError: No module named 'django-last-used' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-last-used'
ModuleNotFoundError: No module named 'django-last-used'  Hi, My... named 'django-last-used' How to remove the ModuleNotFoundError: No module named 'django-last-used' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-user-agents-last'
ModuleNotFoundError: No module named 'django-user-agents-last'  Hi...: No module named 'django-user-agents-last' How to remove the ModuleNotFoundError: No module named 'django-user-agents-last' error? Thanks   
ModuleNotFoundError: No module named 'd-save-last'
ModuleNotFoundError: No module named 'd-save-last'  Hi, My Python... 'd-save-last' How to remove the ModuleNotFoundError: No module named 'd-save-last' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'itunes-last-export'
ModuleNotFoundError: No module named 'itunes-last-export'  Hi, My... named 'itunes-last-export' How to remove the ModuleNotFoundError: No module named 'itunes-last-export' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'last-train-to-nowhere'
ModuleNotFoundError: No module named 'last-train-to-nowhere'  Hi...: No module named 'last-train-to-nowhere' How to remove the ModuleNotFoundError: No module named 'last-train-to-nowhere' error? Thanks   Hi
ModuleNotFoundError: No module named 'last-train-to-nowhere'
ModuleNotFoundError: No module named 'last-train-to-nowhere'  Hi...: No module named 'last-train-to-nowhere' How to remove the ModuleNotFoundError: No module named 'last-train-to-nowhere' error? Thanks   Hi

Ads