Question: Q 1 . Solve the following problems with Java codes for the following two int type arrays: int [ ] values A = { 1

Q1. Solve the following problems with Java codes for the following two int type arrays:
int [] values A={19,9,29,59,39,79,49};
int [] values B={8,18,38,28,48,78,48};
a. Swap the contents of the above-mentioned arrays valuesA and values B :
b. Merge the contents of the above mentioned arrays values A and values B into a new int type
array called valuesc. Make sure to declare and create values C with proper size.
c. Find the total sum of the elements in valuesA, and also find the average value. Now print both
the total sum and the average with printf with proper format specifier. The average will have
total field width of 8,2 digits after the decimal and right justified. Also print the following String
variables in the same print statement:
String msgSum = "The sum of all the elements in array valuesA =";
String msgAverage = "The average of the elements in array values A=";
d. Add 100 to all the elements in array valuesB.
e. Shift all the elements of the array valuesA by moving one element to the left:
values A[i]= values A[i+1]
Make sure to set the boundary condition for the loop control variable to be set to:
i valuesA.length -1.
f. Shift all the elements of the array values B by moving one element to the right;
g. Update the elements of array valuesB by swapping the neighboring two elements if lower indexed element is larger than the higher indexed element. Make sure to set the boundary condition for the loop control variable to be set to: i valuesB.length -1
If(valuesB[i]> valuesB[i+1]{
//swap the elements if the condition is met
}
Print the array contents comma separated and observe the output.
h. Use the following nested for loops and apply the same swapping condition and logic for the array valuesB.
for(int i =0; i valuesB.length 1; i++){
for( int j =0; j valuesB.length 1 I; j++){
//swap the elements if the condition is met
}
}
Print the array contents comma separated and observe the output.
Q2. Write java codes using for loop to Count the total number of vowels in the string "The greatest glory in living lies not in never falling, but in rising every time we fall." Use for loop.
Q 1 . Solve the following problems with Java

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 Programming Questions!