sky grey
last question
1 Answer(s)      a year and 4 months ago
Posted in : Java Beginners

  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 Pages:
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
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
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
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
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
Core Java Interview Question, Interview Question
by last-in-first-out rule (LIFO), while queues use the FIFO rule Question: You can... Core Java Interview Question Page 2       Question: Does it matter
Core Java Interview Question, Interview Question
Core Java Interview Question Page 24       Question: Why do we need public static void main... not have a public constructor? Question: What is the difference between
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
Core Java Interview Question, Interview Question
and constructor for the most derived class completes last. Question: What... Core Java Interview Question Page 25       Question: What are null or Marker
Mysql last day of month
Mysql last day of month       Mysql Last Day of Month is useful to provide you the last day... from Mysql Last Day of Month. To understand the example we use (Last Day (now
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
Java Objectives Question
the file's name, size, and time of last modification. Save the file... and last modification date & time. import java.io.*; import java.util.... hh:mm"); System.out.println("File Last Modified: "+sdf.format(d
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
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
JSP Login Page Question
users first registered and then after they can login. my question is how a user...;"></td></tr> <tr><td>Last Name:</td>..."></td></tr> <tr><td>Last Name:</td><td><
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
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(now
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
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
Java interview question
;User Identifier>,<First name>,<Last name> User records... name,Last name are not the same for each line) They gave an eclipse environment
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
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
C Program Question - Development process
C Program Question  How i can calulate sum of First digit and last... first,last; int sum,num; clrscr(); printf("Enter five digit number...; } first=list[0]; last=list[4]; sum=first+last

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.