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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sky grey
last question
1 Answer(s)      3 years 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
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   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
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
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
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
could get the last results only from resultset,please correct this how to set
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
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
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
Advertisements
 

 

 

DMCA.com