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 nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
- Statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is: There are 15 people.arrow_forward*In Java Problem Description and Given Info Write a public static method named countGreaterThanAverage that will take an int array as it's only argument. This method will return an int value. When called, and passed an array of int values, this method will compute and return the number of values in the argument array that are greater than the average of all the values in the argument array. Here are some examples: Example 1 Given: int[] myArray = {1, 2, 3, 4, 5}; countGreaterThanAverage(myArray) should return 2 Example 2 Given: int[] myArray = {13, 7, 6, 5, 99, 10, 4, 8}; countGreaterThanAverage(myArray) should return 1 Example 3 Given: int[] myArray = {1, 1, 1}; countGreaterThanAverage(myArray) should return 0 Helpful Info: You may want to write a main method to call and test your required method There should be no System.out.print or System.out.println statements in your countGreaterThanAverage method There should be no calls to any Scanner methods (like next, nextLine, or…arrow_forwardQ1. amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { balance = balance + amount ; } // modified toString() method public String toString() { return "Account: " + actNum + "\tName: " + nameOnAct + "\tBalance: " + amount ; } } Q2. amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { // scope of amount starts here balance = balance + amount ; // scope of amount ends here } public void processCheck( int amount ) { // scope of amount starts here int charge; incrementUse(); if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // scope of amount ends here }…arrow_forward
- 1. Write a program that takes three numbers (a,b,c) from the user as input and finds the median of the three. The program has a method called median that takes 3 numbers as the parameter and returns the median. Use if-then-else statements to find the median. You can assume the three numbers are not the same. Sample Example: Enter 3 numbers 10 13 The median is 10 public class Median{ public static void main(String[] args){ Scanner input = new int a = int b = int c =arrow_forwardJavaarrow_forwardpublic class Course{String name;String dept;int number;public Course (String n, String d, int n){name = n;dept = d;number = n;}public String toString(){return "Course " + name + " in " + dept + " #: " + number;}public static void main (String [] args){Scanner in = new Scanner(System.in);add 10 lines using the scanner and saving them as strings The input for each line will be entered a String, a space, another String, and an int. Parse the input string into those three items and make an instance of Course. Add the new Course instance to a generic ArrayList of Course. print out each Course in the ArrayList.arrow_forward
- // Some circle statistics public class DebugFour2 { publicstaticvoidmain(Stringargs[]) { double radius =12.6; System.out.println("Circle statistics"); double area = java.Math.PI * radius * radius; System.out.println("area is " + area); double diameter =2- radius; System.out.println("diameter is + diameter); } }arrow_forwardJava Scriptarrow_forwardIn python and include doctring: First, write a class named Movie that has four data members: title, genre, director, and year. It should have: an init method that takes as arguments the title, genre, director, and year (in that order) and assigns them to the data members. The year is an integer and the others are strings. get methods for each of the data members (get_title, get_genre, get_director, and get_year). Next write a class named StreamingService that has two data members: name and catalog. the catalog is a dictionary of Movies, with the titles as the keys and the Movie objects as the corresponding values (you can assume there aren't any Movies with the same title). The StreamingService class should have: an init method that takes the name as an argument, and assigns it to the name data member. The catalog data member should be initialized to an empty dictionary. get methods for each of the data members (get_name and get_catalog). a method named add_movie that takes a Movie…arrow_forward
- // This program assigns values to two variables // and performs mathematical operations with them public class DebugFour1 { public static void main(String args[]) { int x = 5; int y = 8; int z = 19; System.out.println("adding " + x + y); System.out.println("subtracting " + y - z); System.out.println("dividing " + z / x); System.out.println("multiplying " + x / z); } }arrow_forwardAnalyze the following code. public class Test { public static void main(String[] args){ System.out.printlin( m(2) ); public static int m( int num ) { return num; } public static void m( int num ) { System.out.printin( num ); } The program has a compile error because the second m method is def method. The program runs and prints 2 once.arrow_forward" *", or "/"). The method should throw ar Write a method that computes the value of an arithmetic expression. The operator string should be one of ("+",' IllegalArgumentException otherwise. Also throw an IllegalArgumentException if the operator is "/" and the second argument is zero. II II Arithmetic.java 1 public class Arithmetic 2 { /** Computes the value of an arithmetic expression @param valuel the first operand @param operator a string that should contain an operator + @param value2 the second operand @return the result of the operation */ public static int compute(int valuel, String operator, int value2) { if (operator.equals("+")) { return . . .; } else if (operator.equals ("-")) { return else if (operator.equals ("*")) { return else if (operator.equals("/")) { 4 * or / 7 8. 9 10 11 12 } } 13 14 15 16 17 } else 18 19 20 21 } } 22 23 24arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education