In java just add code between the comments public class A6 { /** * In this Java file, you will write three methods that will ensure that the calls in the main methods are * properly executed. You do NOT have to change anything in the main() method. You have to write the methods that * will complete the program. * * Pay attention to the method name, the method return type, and the method parameters. */ public static void main(String[] args) { /*Your first method will ask user to enter two values and return the exponent where the first number will be the base and the second will be the exponent. Remember to use a mathematical function. If the user enters value 1 as 2 and value 2 as 3, output of your method should be 8 (2 raised to power 3) */ double calculatedExponent = exponentCalculator(); System.out.println(calculatedExponent); //this should print out the exponent value /* Your second method will have two parameters. The first is a String and the second is a number. The method should return the character at that position of the string. E.g., charAtPosition("Hello", 1) should return 'e' The count begins at 0. If the number is greater than the length then your method should print an message saying it is an invalid number.*/ char charFound = charAtPosition("This is a random string", 5); System.out.println(charFound); //to help you test: this should print out 'i'. // Your third method will check if a string contains one of multiple numbers and return true if it does. // E.g., hasNumber("hello123") should return true but hasNumber("hello") should return false. boolean numberFound = hasNumber("CSC210"); System.out.println(numberFound); //to help you test: this should print out true } /** * Below this, write your methods. Remember to put proper comments where necessary. * * Again, pay attention to the method name, method return type, and method parameters. You do NOT have to change * anything in the main method above. * * Tip: read the main method carefully to understand what the method name should be and what paramaters it should * have. To find the return type, look at the variable that is going to store whatever value your method returns. * * Second tip: to test each of your method, comment out the other lines that you see. For example, to test * exponentCalculator() method, comment out lines 22, 23, 29, and 30. To test charAtPosition method, comment out * lines 14, 15, 29, and 30. To test hasNumber method, comment out lines 14, 15, 22, 23. * To comment out means adding // before the line. * Critical: remember to uncomment the commented out lines before submitting. Uncomment means deleting the // that * you may have added. * */
In java just add code between the comments
public class A6 {
/**
* In this Java file, you will write three methods that will ensure that the calls in the main methods are
* properly executed. You do NOT have to change anything in the main() method. You have to write the methods that
* will complete the program.
*
* Pay attention to the method name, the method return type, and the method parameters.
*/
public static void main(String[] args) {
/*Your first method will ask user to enter two values and return the exponent where the first
number will be the base and the second will be the exponent. Remember to use a mathematical function.
If the user enters value 1 as 2 and value 2 as 3, output of your method should be 8 (2 raised to power 3)
*/
double calculatedExponent = exponentCalculator();
System.out.println(calculatedExponent); //this should print out the exponent value
/* Your second method will have two parameters. The first is a String and the second is a number. The method
should return the character at that position of the string. E.g.,
charAtPosition("Hello", 1) should return 'e'
The count begins at 0. If the number is greater than the length then your method should print an message
saying it is an invalid number.*/
char charFound = charAtPosition("This is a random string", 5);
System.out.println(charFound); //to help you test: this should print out 'i'.
// Your third method will check if a string contains one of multiple numbers and return true if it does.
// E.g., hasNumber("hello123") should return true but hasNumber("hello") should return false.
boolean numberFound = hasNumber("CSC210");
System.out.println(numberFound); //to help you test: this should print out true
}
/**
* Below this, write your methods. Remember to put proper comments where necessary.
*
* Again, pay attention to the method name, method return type, and method parameters. You do NOT have to change
* anything in the main method above.
*
* Tip: read the main method carefully to understand what the method name should be and what paramaters it should
* have. To find the return type, look at the variable that is going to store whatever value your method returns.
*
* Second tip: to test each of your method, comment out the other lines that you see. For example, to test
* exponentCalculator() method, comment out lines 22, 23, 29, and 30. To test charAtPosition method, comment out
* lines 14, 15, 29, and 30. To test hasNumber method, comment out lines 14, 15, 22, 23.
* To comment out means adding // before the line.
* Critical: remember to uncomment the commented out lines before submitting. Uncomment means deleting the // that
* you may have added.
*
*/
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images