Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
Question
Book Icon
Chapter 30, Problem 30.9PE
Program Plan Intro

Sort students

Program Plan:

  • Import necessary stream packages into program.
  • Define the class named “Main”.
    • Define main method.
      • Initialize the object “obj” for “Scanner” class.
      • Declare the variable “numberOfStudents” and prompt the value from user.
      • Define the array object for “Student” class.
      • Using “for” loop, get the student name and score from user and store the values into “students[]” variable.
      • Sort the values of “students[]” variable by score and print the results on screen.
    • Define the class named “Student”.
      • Declare the variables “name” and “score”.
      • Define the constructor and initialize the class variables.
      • Define the getters for student name and score.

Blurred answer
Students have asked these similar questions
(Sort students) Rewrite Programming Exercise 7.17 using streams. Define a class named Student with data fields name and score and their getter methods. Store each student in a Student object.package Exercise_30_9; import java.util.Scanner; public class Original { publicstaticvoidmain(String[] args) { Scannerinput = newScanner(System.in); System.out.print("Please enter the number of students:"); intnumStudents = input.nextInt(); double[] scores = newdouble[numStudents]; String[] names = newString[numStudents]; for (inti = 0; i < names.length; i++) { System.out.print("Enter a student name:"); names[i] = input.next(); System.out.print("Enter the students score:"); scores[i] = input.nextDouble(); } sortArray(scores, names); System.out.println("The student names in decreasing order of their scores are: "); for (inti = 0; i < scores.length; i++) { System.out.println(names[i] + " " + scores[i]); } } publicstaticvoidsortArray(double[] arr, String[] array) { for (inti = 0; i <…
(Querying an Array of Invoice Objects) Use the class Invoice provided in the lab assignment to create an array of Invoice objects.Class Invoice includes four properties—a PartNumber (type int), a PartDescription (type string), a Quantity of the item being purchased (type int) and a Price (type decimal).Write a console application that performs the following queries on the array of Invoice objects and displays the results:a) Use LINQ to sort the Invoice objects by PartDescription.b) Use LINQ to sort the Invoice objects by Price.c) Use LINQ to select the PartDescription and Quantity and sort the results by Quantity.d) Use LINQ to select from each Invoice the PartDescription and the value of the Invoice(i.e., Quantity * Price). Name the calculated column InvoiceTotal. Order the results by Invoice value. [Hint: Use let to store the result of Quantity * Price in a new range variable total.]e) Using the results of the LINQ query in Part d, select the InvoiceTotals in the range$200 to…
(Rectangle Class) Create a class Rectangle with attributes length and width, each of whichdefaults to 1. Provide member functions that calculate the perimeter and the area of the rectangle.Also, provide set and get functions for the length and width attributes. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0.

Chapter 30 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education