Q1. Produce a method that reads in a set of values (double) from the user and returns them. Use this header: public static double[] getNumsFromUser (String msgl, String msg2) The implementation of the method should start with a message to input the total number of array elements, followed by a message to enter all the array elements. The method returns the array of elements. The two strings msg1 and msg2 that are passed to the method as parameters will be the two messages that tell the user what to do. In the main class, use the following program outline to test this method: public class Q1 { public static void main(String[] args) { String s1 = "Enter number of students: "; String s2 = "Enter student grades: "; double[] numbers = System.out.println(Arrays.toString(numbers)); getNums FromUser(s1, s2); %3D public static double[] getNumsFromUser(String msg1, String msg2){ //your code goes here } Sample run Enter number of students: 4 Enter student grades: 12.5 23 11.5 27 [12.5, 23.0, 11.5, 27.0]

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Q1.
Produce a method that reads in a set of values (double) from the user and returns
them. Use this header:
public static double[] getNumsFromUser (String msg1, String msg2)
The implementation of the method should start with a message to input the total number of
array elements, followed by a message to enter all the array elements. The method returns
the array of elements. The two strings msg1 and msg2 that are passed to the method as
parameters will be the two messages that tell the user what to do.
In the main class, use the following program outline to test this method:
public class Q1 {
public static void main(String[] args) {
String s1 = "Enter number of students: ";
String s2 = "Enter student grades: ";
double[] numbers = getNumsFromUser(s1, s2);
System.out.println(Arrays.toString(numbers));
public static double[] getNumsFromUser(String msg1, String msg2){
//your code goes here
}
Sample run
Enter number of students: 4
Enter student grades: 12.5 23 11.5 27
[12.5, 23.0, 11.5, 27.0]
39%
9°C
T80
F11
F4
F5
F6
F7
F8
F9
F10
(8)
Transcribed Image Text:Q1. Produce a method that reads in a set of values (double) from the user and returns them. Use this header: public static double[] getNumsFromUser (String msg1, String msg2) The implementation of the method should start with a message to input the total number of array elements, followed by a message to enter all the array elements. The method returns the array of elements. The two strings msg1 and msg2 that are passed to the method as parameters will be the two messages that tell the user what to do. In the main class, use the following program outline to test this method: public class Q1 { public static void main(String[] args) { String s1 = "Enter number of students: "; String s2 = "Enter student grades: "; double[] numbers = getNumsFromUser(s1, s2); System.out.println(Arrays.toString(numbers)); public static double[] getNumsFromUser(String msg1, String msg2){ //your code goes here } Sample run Enter number of students: 4 Enter student grades: 12.5 23 11.5 27 [12.5, 23.0, 11.5, 27.0] 39% 9°C T80 F11 F4 F5 F6 F7 F8 F9 F10 (8)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education