Please provide me with the coding for a program that prompts the user to enter the number of student's, the student's name, and the student's test score.

Hi. I need the coding for this problem. I am not even sure where to start. This is what I need. Write a java program that prompts a user to enter the number of students, the student's name, and the student's test score. The output will be the student's names and matching scores in decreasing order of their scores. This program MUST use arrays, MUST use methods, and MUST use a bubble sort. Any help would be greatly appreciated.

Thank you.

View Answers

April 12, 2011 at 2:49 PM

import java.io.*;
import java.util.*;

class ShowData implements Comparable {
        String name;
        int marks;

        public void setName(String name) {
                this.name = name;
        }

        public String getName() {
                return name;
        }

        public void setMarks(int marks) {
                this.marks = marks;
        }

        public int getMarks() {
                return marks;
        }
        public int compareTo(Object Student) throws ClassCastException {
                if (!(Student instanceof ShowData))
                        throw new ClassCastException("Error");
                int mm = ((ShowData) Student).getMarks();
                return this.marks - mm;
        }
}

public class StudentData {
              public static void main(String[] args) {
              Scanner input=new Scanner(System.in);
              System.out.print("Enter number of students: ");
              int num=input.nextInt();
              int j = 0;
                ShowData data[] = new ShowData[num];
                for(int i=0;i<data.length;i++){
                System.out.print("Enter Name: ");
                String name=input.next();
                System.out.print("Enter Marks: ");
                int marks=input.nextInt();

                                data[i] = new ShowData();
                                data[i].setName(name);
                                data[i].setMarks(marks);
                }
                        Arrays.sort(data,Collections.reverseOrder());
                        for (int i = 0; i < num; i++) {
                                        ShowData show = data[i];
                                        String name = show.getName();
                                        int marks = show.getMarks();
                                        System.out.println(name+"\t "+marks);
                        }
              }
}









Related Tutorials/Questions & Answers:
PLEASE Help me write a Java program which will store, manipulate, and print student registration information.
PLEASE Help me write a Java program which will store, manipulate, and print... Student must have the following fields ââ?¬â?? Name, Address, Id number, Courses... THE COURSE INFORMATION, AND ALSO NEED THE TEST CLASS ALREADY HAVE THE NAME
student
how many times has the user guessed a number. The program should display user win if the number user has guess the correct number. If not ask user to enter a number again until user has entered the correct number. The program should allow
Advertisements
Student
Student  Is Agitar Software used for generating junit test cases for Texlipse plugin in eclipse IDE? If yes, how? what should be the input values to the project
student
student  how do i create a program that writes out the message :Welcome to Kaplan University!"   Hi Friend, Try the following code: class Message { public static void main(String[] args
Student average
that reads student's number of subject taken, the final grade of each subject. your program should display and the number of units of each subject. your program... Enter number of subjects: 3 Enter subject1 grade: 1.6 Enter number of units
Student Marks
Student Marks  Hi everyone I have to do this java assignment, and having trouble with it please help me. Write a program to compute the computer..., previous grade, this yearââ?¬â?¢s grade, percentage, and student number
student information system
student information system  can you show me example of "student information system" pseudo code and flow chart with "student name, student id, student residential hall, student course, student phone numbers
student database
student database  student records such as fees-school fees, dob,age,if any due.the record stored should be like this record,name,age,dob,fee list or any dues of the student record1 isha 15 20jan record2 spandana 14 4feb record3
student info
student info  code of insert,delete,update,view,search of student information using jsp and servelts   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 http://www.roseindia.net/jsp/user-search.shtml http
Student database
Student database  Create a class Student with Name, Gender, and Date of Birth and Input Student and print as ?Dear Mr/Mrs Name, your Age is 99 Years?. Mr/Mrs - only one should be displayed based on their age and Gender
Write a program to get student details and store in a database
Write a program to get student details and store in a database  Write a program to get student details and store in a database
STUDENT MANAGEMENT SYSTEM
STUDENT MANAGEMENT SYSTEM  can any one help me with the coding if this using awt please!!!!!!! STUDENT MANAGEMENT SYSTEM Table details Student (STUDENTID, NAME, ADDRESS, PHONE, MAILID, COURSEID (Foreign Key)) Course (COURSEID
student details
student details  hi sir/madam i have a doubt in PHP how to insert student details using mysql with php..   Have a look at the following link: PHP Mysql insert
student details
student details  create an application for details of 1st to 5th standard students by using loops and scanner
Student Marks
Student Marks  Create a simple application which can calculate 5 marks entered by user and find the grade. Create a simple application which can calculate 5 marks entered by user and find the grade. You must display the grade
school student attendence report
school student attendence report  Hi i want school student attendence genaration source code please urgent help me
Java GUI to build a Student Registration Program
Java GUI to build a Student Registration Program   Write a program... in sorted order by last name. Demonstrate the correct operation of your program by creating a driver program to load the student data base and the course data
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Write a program that prompts the user to enter the number of students and each studentâ??s name and score, and finally displays the name of the students
project for Student Admission System
project for Student Admission System  I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way
Jdbc Program for building Student Information Database - JDBC
Jdbc Program for building Student Information Database  import... TextArea(10,2); l1=new Label(&quot;Enter student info&quot;); l2=new... containing student name,address,ph.,e-mail,gender,date of birth should appear
how to validate e,ail id and phne number in student form
how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Visit Here Thanks
how to validate e,ail id and phne number in student form
how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Visit Here Thanks
html code for student information?
html code for student information?  html code for student information
student weekly attandence genaration
student weekly attandence genaration  Hievery body iam doing student project in that i want student weekly ,yearly attendence generation report... please help it is very urgent iam a beginer thanks
college student admission
college student admission  Front End -JAVA Back End - MS Access Hello Sir, I want College Student Admission Project in Java with Source code, that includes Following Forms 1) Student Admission based on Enterance Exam Marks
student admission system project
student admission system project  College Student Admission System... Student Admission Project in Java with Source code, that includes Following Forms 1) Student Admission based,its urgent sir
Write a JSP program to display the grade of a student by accepting the marks of five subjects.
Write a JSP program to display the grade of a student by accepting the marks of five subjects.  Write a JSP program to display the grade of a student by accepting the marks of five subjects
creating an applet for student management system
in the appropriate layout, and responds to the user's actions. The program simulates... it to act), and reasonably realistic. It must accept the student id,name,age,address...creating an applet for student management system  Write an applet/awt
data science student jobs
student jobs Try to provide me good examples or tutorials links so that I can learn the topic "data science student jobs". Also tell me which...data science student jobs  Hi, I am beginner in Data Science
Student - Java Beginners
Student  Create a class named Student which has data fields of student metric number, mark for the quizzes (15% from the total mark), lab assignments (15%), first test (15%), second test (15%), final exam (40%), total mark (100
student attendence report
student attendence report  Hi every body iam doing a school project... student attendence daywise ,monthly ,halfyearly and yearly how i generate plz send me code urgent any one can help me. thnks
how to validate e,ail id and phne number in student form
how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Try...==""){ alert("Enter Phone Number!"); } else if(regExpObj.exec(ph) == null
Tutorial college Student Admission System
Tutorial college Student Admission System  I want PHP Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way..... please send me synopsis
Student Management System
Student Management System  Hi , Friend can i get the solution for connecting login page of JFrames to JDBC
I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way.....
I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way.....  I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please
Please provide the coding for this problem
Please provide the coding for this problem  Please provide the coding... a word and prompts the user to guess one letter at a time. Each letter in the word... letter is then displayed. When the user finishes a word, display the number of misses
student registration example
;*/ if(name =="" ||name == null ) { alert("user id cannot be blank... false;*/ if(name =="" ||name == null ) { alert("user id...student registration example  1.reg.jsp <%@ page language="java
ModuleNotFoundError: No module named 'student-bsu-by'
ModuleNotFoundError: No module named 'student-bsu-by'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'student-bsu-by' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'student_evaluator'
ModuleNotFoundError: No module named 'student_evaluator'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'student_evaluator' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'student-mixture'
ModuleNotFoundError: No module named 'student-mixture'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'student-mixture' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'student-rishiraj'
ModuleNotFoundError: No module named 'student-rishiraj'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'student-rishiraj' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'student_ubl'
ModuleNotFoundError: No module named 'student_ubl'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'student_ubl' How to remove the ModuleNotFoundError: No module named '
genarating student weekly progress report
genarating student weekly progress report  Hi every one iam using struts frame work backend as oracle 10g . i want code for how to genarate student weekly and monthly marks . thanks in advance
please help me in coding this given program
please help me in coding this given program  consider the below... are the prime numbers in ascending order write a program to find the nth term in this series. (i m unable to code this program..please provide solution
please help me in coding this given program
please help me in coding this given program  consider the below... are the prime numbers in ascending order write a program to find the nth term in this series. (i m unable to code this program..please provide solution
student marks sheet genaration in struts frame work
student marks sheet genaration in struts frame work  Hi every body iam using struts frame work back end as oracle 10g xe i wanna urgent code for student marks genaration code please help me thanks in advance
program to create student report using java applet,read the input using text boxesand generate the grades..?
program to create student report using java applet,read the input using text boxesand generate the grades..?   sir plz give me java applet codes for above question
Write a program using JSP that enables any student to change his/her address.
Write a program using JSP that enables any student to change his/her address.  Write a program using JSP that enables any student to change his/her address
sorting student record - Java Beginners
sorting student record  Program in java for inserting, recording, deleting, editing and searching student details   can u explain about...("Enter Choice : "); choice = Integer.parseInt(br.readLine()); switch