Trying to create a 2 dimensional array for converting temperature and returning max. Having problems declaring max such as these 2 lines.
max = max(inputFahr[0][0]);
max2 = max2(inputCel[0][1]);
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package project3;
import java.util.Scanner;/**
*
*/
public class Program7 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double fahrenheit; // degrees in Fahrenheit
double celsius; // degrees in Celsius
int choice; // 1 for F to C and 2 for C to F
celsius = 0;
fahrenheit = 0;
double max;
double max2;
max = max(inputFahr[0][0]);
max2 = max2(inputCel[0][1]);
do {
System.out.print("Enter 1 for F to C, 2 for C to F, and 3 to quit");
choice = input.nextInt();
if (choice == 1)
celsius = tempC(celsius);
else if (choice == 2)
fahrenheit = tempF(fahrenheit);
else if (choice == 3)
exit();
else System.out.println("Invalid selection");
System.out.println("Maximum temperature is " + max);
System.out.println("Maximum temperature is " + max2);
} while (choice != 3);
}
public static double tempC (double celsius) {
Scanner input = new Scanner(System.in);
System.out.print("Enter degrees fahrenheit");
double fahrenheit = input.nextDouble();
double[][] inputFahr = new double[10][2];
for (int i = 0; i < inputFahr.length; i++)
inputFahr[i][0] = fahrenheit ;
celsius = (5.0/9)*(fahrenheit - 32);
for (int i = 0; i < inputFahr.length; i++)
inputFahr[i][1] = celsius;
System.out.println(fahrenheit + " degrees fahrenheit equals " +
celsius + " degrees celsius");
return celsius;
}
public static double max(double[][] inputFahr) {
double max = inputFahr[0][0];
for (int i = 0; i < inputFahr[i].length; i++) {
if (inputFahr[i][0] > max)
max = inputFahr[i][0];
}
return max;
}
public static double tempF (double fahrenheit) {
Scanner input = new Scanner(System.in);
System.out.print("Enter degrees celsius");
double celsius = input.nextDouble();
double[][] inputCel = new double[10][2];
for (int i = 0; i < inputCel.length; i++)
inputCel[i][1] = celsius ;
fahrenheit = (9.0/5)* celsius + 32;
for (int i = 0; i < inputCel.length; i++)
inputCel[i][0] = fahrenheit;
System.out.println(celsius + " degrees celsius equals " +
fahrenheit + " degrees fahrenheit");
return fahrenheit;
}
public static double max2(double[][] inputCel) {
double max2 = inputCel[0][1];
for (int i = 0; i < inputCel[i].length; i++){
if (inputCel[i][1] > max2)
max2 = inputCel[i][1];
}
return max2;
}
public static void exit (){
System.out.println("Goodbye");
// TODO code application logic here
}
}