You will be required to demo your homework solutions during lab.
1) Complete the main() method of the program we started in class, adding an else block so that when the user enters a negative number, an error message is generated.
public static void main(String[] args) {
String inputValue = JOptionPane.showInputDialog(
"Enter a value:");Scanner stringReader =
new Scanner( inputValue ); // create a Scanner that can convert Strings to numeric values double value = stringReader.nextDouble(); // convert the user inputString to a double (if possible)System.
out.println("The value is " + value ); if( value >= 0 ) {value = Math.sqrt( value );
// compute the square root of the value and reassign the result to the same variableSystem.
out.println("The square root of the value is " + value );}
}
2
) Write another program that prompts the user to enter a positive integer value from 5 to 9. Use nested if conditionals to: