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());
        }
    }
}

Ads









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
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
Advertisements
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?  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
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
Mysql last day of month
Mysql last day of month       Mysql Last Day of Month is useful to provide you the last... an example from Mysql Last Day of Month. To understand the example we use
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
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
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
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
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
Mysql Last Record
Mysql Last Record       Mysql Last Record is used to return the last records from table... an example from 'Mysql Last Record'. To understand example we create a table
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
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
Mysql last row
Mysql last row       Query to Create Table named employee1:- mysql>CREATE TABLE... to view last row of Table named employee1:- mysql> select * from
Question on pooling
Question on pooling  which server supports pooling?Application server or web server
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
C# question
Create a Solution by name Bank with Classes Account.cs, SavingsAccount.cs and savingsTest.cs to Demonstrate Abstract Classes in C#  1st question : Create a Solution by name Bank with Classes Account.cs, SavingsAccount.cs
question for c++
question for c++   write Program to swap between two numbers if first number is greater than second number and total of two numbers greater than 10
Inheritance question?
Inheritance question?  Q3)Create a class hierarchy as Company extended by AccountsDepartment. AccountsDepartment extended by AccountsReceivable... as AccountsPayable. please send the code of this question soon....plzzzzzzzz  

Ads