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



Home Answers Viewqa Java-Beginners 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.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Bryan Noll
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.
1 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


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.


Advertisement
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:
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
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
Advertisements
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
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 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 info
student info  code of insert,delete,update,view,search of student information using jsp and servelts   Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http
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 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
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 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 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
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
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
school student attendence report
school student attendence report  Hi i want school student attendence genaration source code please urgent help me
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
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
html code for student information?
html code for student information?  html code for student information
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
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
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
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 - 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
Student Management System
Student Management System  Hi , Friend can i get the solution for connecting login page of JFrames to JDBC
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
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
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
Advertisements
 

 

 

DMCA.com