Write a Java program method named reversal that returns a newarray that is a rev
ID: 3618467 • Letter: W
Question
Write a Java program method named reversal that returns a newarray that is a reversal of the original array. Use [5.0, 4.4, 1.9,2.9, 3.4, 3.5] to test the method. Also, the reversal method is tosend the minimum item of the array.
Output Sample:
//Assignment Name: -Assignment4ReadIntegers.java
//Read integers and find the total and average of input values, notcounting zeros
import javax.swing.*;
public class Numbers
{
public static void main(String[] args)
{
//initialise variables
int count=0;
double average;
int total=0;
int largest=0;
int smallest=0;
int value;
boolean enter=true;
do
{
//To get the input fromthe user
String lengthString =JOptionPane.showInputDialog ("Enter a Number.Enter 0 toStop.");
value =Integer.parseInt(lengthString);
if(count==0)
smallest=value;
//Tocalculate total
total=total+value;
//Tocalculate no of entries
if(value!=0)
count++;
//Greater Number
if(value>largest)
largest=value;
//Smallest Number
if(value!=0 &&value<smallest)
smallest=value;
if(value==0)
enter=false;
}while(enter==true);
average=(double)total/count;
JOptionPane.showMessageDialog(null, "The total is "+total+". TheAverage is "+average+". The largest value is "+largest+". Thesmallest value is "+smallest+". The number of entries is"+count+".");
}
}
Explanation / Answer
please rate - thanks import javax.swing.*; public class untitled { public static void main(String[] args) { //initialise variables int count=0,i; double smallest=0; double[]a=newdouble[10]; //To get the input fromthe user String str =JOptionPane.showInputDialog ("Enter a Number.Enter 0 toStop."); a[count]=Double.parseDouble(str); while(a[count]!=0) { count++; StringlengthString = JOptionPane.showInputDialog ("Enter a Number.Enter 0to Stop."); a[count] =Double.parseDouble(lengthString); }; str="Original String:"; for(i=0;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.