Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


sky grey
last question
1 Answer(s)      2 years and 8 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)

Advertisement
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
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
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
php remove last character
php remove last character  to remove the last character, i used the trim function which is not working
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... an example from Mysql Last Day of Month. To understand the example we use
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
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
could get the last results only from resultset,please correct this how to set
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
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
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
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
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
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
Mysql Last Record
Mysql Last Record       Mysql Last Record is used to the return the record using... in set (0.00 sec) Query to view last record of  Table named
Getting the last inserted id using jsp
Getting the last inserted id using jsp  Pls how can i retrieve the last inserted id after submitting a form to mysql using jsp
date_get_last_errors
date_get_last_errors date_get_last_errors alias DateTime::getLastErrors function returns the warnings and errors while parsing a date/time string. Description public static array DateTime::getLastErrors ( void ) Parameters
Pointing last index of the Matcher
Pointing last index of the Matcher   ... and also indicate the last index of the matcher using expression.For this we... will arrive.":- Declaring text as String in which last index of word Tim
Sort last modified file time in java
Sort last modified file time in java  How to sort the last modified file time in java?   import java.io.*; import java.util.*; import..."); System.out.println("Last modification time : " + sdf.format(d)); } else
help regarding creation of last year project
help regarding creation of last year project  i dont know whether i picked up the right category or not. actually m a last year bsc it student. i want to develop a website I-NAVIGATOR like the m-indicator mobile app. i want
Mysql Last Row
Mysql Last Row       Mysql Last Row is used to return the last records from table. Understand with Example The Tutorial illustrate an example from 'Mysql Last Row'. To understand
JDBC: Last Inserted Id Example
JDBC: Last Inserted Id Example In this tutorial, you will learn how to find last inserted record ID using JDBC API. Getting Last Inserted ID : Last... insertion.  you can get the last inserted id by using MAX(), writing
Java file last modified date
Java file last modified date In this section, you will learn how to get the last modification date and time of any file or a directory. Java IO has provide... it. You can use the lastModified() method to get the file?s last modified
Mysql Date Last 30 Days
Mysql Date Last 30 Days       Mysql is used to find out the last 30 days from current date. Understand with Example The Tutorial illustrate an example from 'Mysql Date Last 30
C file Last Modified Date
C file Last Modified Date       This section demonstrates you to find the last modified date of file in C.  You can see in the given example that we want to get the last
Java Get Last Line of File
Java Get Last Line of File     ... you in understanding Get Last Line of File in Java . For this we have a class name "Get Last Line of File". Inside the main method we create an instance
Session Last Accessed Time Example
Session Last Accessed Time Example      ... of session  and last access time of session. Sessions are used to maintain state.... The getLastAccessedTime() method is used to find when last time session was accessed
Query to insert values in the empty fields in the last row of a table in Mysql database?
Query to insert values in the empty fields in the last row of a table in Mysql database?  I have some fields filled and some fields empty in the last row of my MYSQL database. Now I want to fill up those empty fields in the last
the last data entered into database is getting stored again after refreshing
the last data entered into database is getting stored again after refreshing  hey all i made a shout box using php and mysql but the last data... if the data is deleted from the database the last data entered is getting posted plz help
C calculate sum of first and last element of array
C calculate sum of first and last element of array In this section, you will learn how to calculate sum of first and last element from the array of five... and the last number and determine their sum. Here is the code
how to find last day 0f any given month in mysql?
how to find last day 0f any given month in mysql?  how to find last day of any given month in mysql?   Hi Friend, Here is required code: DECLARE @dtDate DATETIME SET @dtDate = '8/18/2007' SELECT DATEADD(s,-1,DATEADD
Question on pooling
Question on pooling  which server supports pooling?Application server or web server
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
Advertisements
 

 

 

DMCA.com