Question: Floating - point number firstNum is read from input. Declare an array of floating - point numbers, named userNums, with size NUM _ VALS. Then,

Floating-point number firstNum is read from input. Declare an array of floating-point numbers, named userNums, with size NUM_VALS. Then, assign the elements of userNums with firstNum, firstNum +1, firstNum +2, and so on, until all elements have been assigned.
Ex: If the input is 56.4, then the output is:
Array values: 56.457.458.459.4 import java.util.Scanner;
public class UserData {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
final int NUM_VALS =4;
double firstNum;
int i;
firstNum = scnr.nextDouble();
/* Your code goes here */
System.out.print("Array values: ");
for (i =0; i < userNums.length; ++i){
System.out.print(userNums[i]+"");
}
System.out.println();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!