Write a method that takes two strings as parameters

Assignment Help JAVA Programming
Reference no: EM131590817

1. Consider the following program:

public class Whatzit {

public static void main(String[] args) {
int i = 10;
int k = 0;
while (i < 100) {
int j = whatzit(i);
k = k + j;
i = i * 10;
}
System.out.println("The final value is : "+k);
}

private static int whatzit(int k) {
int i = 10;
int j = 0;
while (i > 0) {
j = j + i*k;
i = i - 1;
}
return j;
}
}
What lines are in the scope of the variable i declared at line 4?
What lines are in the scope of the variable j declared at line 7?
What lines are in the scope of the variable j declared at line 16?
What is the final output of this program? Try to trace this program - don't just plug it into Eclipse and run it to see what it does. (You can do that to check your work however).

2. For the following program, give the output produced by the program:

public class ChangeParam
{
public static void main(String[] args)
{
int i = 1;
double x = 3.4;
String s = "hi!";

System.out.println(i + " " + x + " " + s);
changeUs(i, x, s);
System.out.println(i + " " + x + " " + s);
}

private static void changeUs(int j, double y, String t)
{
j = 7;
y = -1.2;
t = "there";
System.out.println(j + " " + y + " " + t);
}
}

3. Write a method that takes two Strings as parameters and returns true if the second String is the reverse of the first String. Otherwise it should return false. In addition, write a main method that tests your method for a variety of conditions where it should return false and a variety of conditions where it should return true.

4. Write a method that takes two integers as parameters and returns true if the first integer is evenly divisible by the second integer, false otherwise. For example, if the integers are the pair (55, 5) the method should return true, while if the integers are the pair (55,6) the method should return false. In addition, write a main method that tests your method for a variety of conditions where it should return true and a variety of conditions where it should return false.

5. Write a method that takes a String as input and returns a String containing the middle character of the String if the length of that String is odd. If the length of the String is even, your method should return the middle two characters. For example, if the input String is "Hello" the method should return "l" and if the input String is "Worlds" the method should return "rl". In addition, write a main method that tests your method for a variety of String values.

6. REVIEW: According to the Section Information page for the course, when is your final exam scheduled? According to the Course Policies page, how many points will you lose off your final exam if you want to leave before your exam is scheduled during finals week? Make sure any travel plans you have for the end of the semester include you being here on the scheduled date of your final exam.

Reference no: EM131590817

Questions Cloud

Calculate the amount of cash that skifurn expects : The company has a selling price of $10 per unit, Calculate the amount of cash that Skifurn expects to collect in February
What was the initial temperature of the pan : A 800 g aluminum pan is removed from the stove and plunged into a sink filled with 13.0 L of water at 19.5°C. The water temperature quickly rises to 24.0°C.
Examine types of biases : Examine at least two (2) types of biases that you likely experienced as you evaluated the premises for and against your position.
What advice would you give them on negotiating future joint : If you were Monarch Associates' in-house counsel, what advice would you give them on negotiating future joint ventures with Russian businesses?
Write a method that takes two strings as parameters : Write a method that takes two Strings as parameters and returns true if the second String is the reverse of the first String. Otherwise it should return false.
What is the ke of the electron : What is the KE of the electron just as it reaches the positive plate?
Explain the concepts of information systems security : The CIO has seen reports of malicious activity being on the rise and has become extremely concerned with the protection of the intellectual property and highly.
Describe the specifics of what was done : Regarding the total quality management- Which of the following specific quality program tactics were involved? Describe the specifics of what was done.
Statements concerning depreciation expense : Which of the following statements concerning depreciation expense is most correct?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd