Java

<pre>package com.company; import java.util.Scanner; public class Main { //prints string to console private static void print(String s) { System.out.println(s); } //all the constants for given R values returns the correct R value private static double rValues(String pressure){ double R = 0; if(pressure.equalsIgnoreCase("atm")){ R = 0.082057338; }else if(pressure.equalsIgnoreCase("tor")){ R = 62.363577; }else if(pressure.equalsIgnoreCase("mmHg")){ R = 62.36367; } return R; } //all of the equations solved for unknown variable private static double solve_P(double[] variables, double constant, double temperature ){ double exitP; exitP = (variables[2]*temperature*constant)/variables[1]; return exitP; } private static double solve_V(double[] variables, double constant, double temperature){ double exitV; exitV =(variables[2]*temperature*constant)/variables[0]; return exitV; } private static double solve_n(double[] variables, double constant, double temperature){ double exitN; exitN = (variables[0]*variables[1])/(constant*temperature); return exitN; } private static double solve_T(double[] variables, double constant){ double exitT; exitT = (variables[0]*variables[1])/(constant*variables[2]); return exitT; } public static void main(String[] args) { //play again loop boolean isRunning = true; String playAgain; while (isRunning) { Scanner keyboard = new Scanner(System.in);//creates scanner //introduction print("This is an ideal gas law solver"); print("PV=nRT"); //what R value to use print("what is the pressure measured in?"); print("atm, tor, or mmmHg"); print(">"); String whatPressure; whatPressure = keyboard.next(); double rConstant; rConstant = rValues(whatPressure); //stored questions String[] userQuestions = {"what is the pressure P", "what is the volume V", "what is the number of moles n"}; //stores answers in userAnswers double[] userAnswers = new double[3]; print("what variable would you like to solve for?"); String unknownVariable; unknownVariable = keyboard.next(); System.out.println("solving for " + unknownVariable); //converts between celsius and kelvin double temperature = 0; if (unknownVariable.compareToIgnoreCase("T") == 0) { print("what is the temperature in?"); print("kelvin (K) or celsius (c) "); String whatTemperatureUnit; whatTemperatureUnit = keyboard.next(); print("what is the temperature?"); temperature = keyboard.nextDouble(); if (whatTemperatureUnit