Problem to solve: 1) You must create an array to hold your (double) temperature values. 2) Display all floating-point (double) numbers to one decimal place. 3) Each static method should only handle one primary task My issues: 1) I can't find how to turn the int[] array (i.e., aList[]) into a double value. Should I do this in the method definitions or main method? 2) in the method definitions, how do I write a mutator method using the values from the aList[i] array? 3) Can I use the fahr variable from toCelsius method & apply to toKelvin method? Java code: import java.util.Scanner; public class Main { /*I can't find how to turn the aList[] array values into double values. Should I do this in the method definitions or main method? */ public void toFahr(int[] array){ } // how do I write a mutator method using the values from the aList[i] array? public static double toCelsius(int[] array){ double fahr; //fahrenheit value double celsius; return celsius = (fahr - 32)/1.8; } // Can I use the fahr variable from toCelsius method & apply to toKelvin method? public double toKelvin( ){ double kelv; return kelv=(fahr -32)/1.8 + 273.15; } //use selectionSort(numbers) later on in main method to call this public static void selectionSort(int [] numbers) { int i; int j; int indexSmallest; int temp; for (i = 0; i < numbers.length - 1; ++i) { // Find index of smallest remaining element indexSmallest = i; for (j = i + 1; j < numbers.length; ++j) { if (numbers[j] < numbers[indexSmallest]) { indexSmallest = j; } } // Swap numbers[i] and numbers[indexSmallest] temp = numbers[i]; numbers[i] = numbers[indexSmallest]; numbers[indexSmallest] = temp; } /* fill out the rest once I get the above public void avg() { } public void high () { } public void low() { } public void aboveAvg( ) { } public void equalAvg() { } public void belowAvg() { } public void stdDev() { } */ public static void main(String[] args) { // write your code here Scanner scnr = new Scanner(System.in); int i = 0; int j = 0; int num,numTemp; System.out.print("How many numbers do you want to enter? : "); num = scnr.nextInt(); int aList[] = new int[num]; //store array from user's input System.out.println("Please enter " + num + " integer from 1 to 35."); for(i=0;i35) { System.out.println(aList[j]+" is not correct!"); while(true) { System.out.println("Please enter within the range of 1-35 or this cycle will loop forever"); numTemp = scnr.nextInt(); if(numTemp>0 && numTemp<36) { aList[j] = numTemp; break; } } } } for(j = 0;j

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

Problem to solve:

1) You must create an array to hold your (double) temperature values.

2) Display all floating-point (double) numbers to one decimal place.

3)

Each static method should only handle one primary task

My issues:

1) I can't find how to turn the int[] array (i.e., aList[]) into a double value. Should I do this in the method definitions or main method?

2) in the method definitions, how do I write a mutator method using the values from the aList[i] array?

3) Can I use the fahr variable from toCelsius method & apply to toKelvin method?

Java code:

import java.util.Scanner;

public class Main {

/*I can't find how to turn the aList[] array values into double values.
Should I do this in the method definitions or main method? */
public void toFahr(int[] array){

}
// how do I write a mutator method using the values from the aList[i] array?
public static double toCelsius(int[] array){
double fahr; //fahrenheit value
double celsius;
return celsius = (fahr - 32)/1.8;
}

// Can I use the fahr variable from toCelsius method & apply to toKelvin method?
public double toKelvin( ){
double kelv;
return kelv=(fahr -32)/1.8 + 273.15;
}
//use selectionSort(numbers) later on in main method to call this
public static void selectionSort(int [] numbers) {
int i;
int j;
int indexSmallest;
int temp;

for (i = 0; i < numbers.length - 1; ++i) {

// Find index of smallest remaining element
indexSmallest = i;
for (j = i + 1; j < numbers.length; ++j) {

if (numbers[j] < numbers[indexSmallest]) {
indexSmallest = j;
}
}

// Swap numbers[i] and numbers[indexSmallest]
temp = numbers[i];
numbers[i] = numbers[indexSmallest];
numbers[indexSmallest] = temp;
}

/* fill out the rest once I get the above
public void avg() {

}

public void high () {

}

public void low() {

}

public void aboveAvg( ) {

}

public void equalAvg() {

}

public void belowAvg() {

}

public void stdDev() {

}
*/

public static void main(String[] args) {
// write your code here
Scanner scnr = new Scanner(System.in);
int i = 0;
int j = 0;
int num,numTemp;

System.out.print("How many numbers do you want to enter? : ");
num = scnr.nextInt();
int aList[] = new int[num]; //store array from user's input
System.out.println("Please enter " + num + " integer from 1 to 35.");
for(i=0;i<num;i++) {
aList[i] = scnr.nextInt();
}
for(j = 0;j<num;j++) {
if(aList[j]<1 || aList[j]>35) {
System.out.println(aList[j]+" is not correct!");
while(true) {
System.out.println("Please enter within the range of 1-35 or this cycle will loop forever");
numTemp = scnr.nextInt();
if(numTemp>0 && numTemp<36) {
aList[j] = numTemp;
break;
}
}
}
}
for(j = 0;j<num;j++) {
System.out.print(aList[j]+" ");
}

}
}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
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
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