Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Integer numElements is read from input, representing the number of floating - point numbers to be read next. Then, the remaining numbers are read and

Integer numElements is read from input, representing the number of floating-point numbers to be read next. Then, the remaining numbers are read and stored into array wagesArray. Write a loop that assigns array rotatedArray with wagesArray's elements shifted to the left by one index. The element at index 0 of wagesArray should be copied to the end of rotatedArray.
Ex: If the input is:
3
250.5260.5220.5
then the output is:
Original wages: 250.5260.5220.5
Updated wages: 260.5220.5250.5
import java.util.Scanner;
public class ArrayModification {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
double[] wagesArray;
double[] rotatedArray;
int numElements;
int i;
numElements = scnr.nextInt();
wagesArray = new double[numElements];
rotatedArray = new double[numElements];
for (i =0; i < wagesArray.length; ++i){
wagesArray[i]= scnr.nextDouble();
}
/* Your code goes here */
System.out.print("Original wages: ");
for (i =0; i < wagesArray.length; ++i){
System.out.printf("%.1f ", wagesArray[i]);
}
System.out.println();
System.out.print("Updated wages: ");
for (i =0; i < rotatedArray.length; ++i){
System.out.print(rotatedArray[i]+"");
}
System.out.println();
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions