Write a method that takes a string as input

Assignment Help JAVA Programming
Reference no: EM131590509

1.

a. What lines are in the scope of the variable i declared at line 16? b. What lines are in the scope of the variable k declared at line 7? c. What lines are in the scope of the variable k declared at line 26? d. Provide a trace table for this program. What is the final output? Keep in mind the scopes of the variables while making your trace table. How many columns will it need? (Trace the program first, then type it into Eclipse to verify your answer).

2. Write a method that takes a String as input and returns the reverse of that String. Then write a second method that uses the first method to test whether or not an input String is a palindrome. Your method should return true if the String is a palindrome, and false otherwise. Palindromes were discussed in Exercise 2 of Closed Lab 06, and you should use the same definition here. In addition, write a main method that tests your method with a variety of Strings that should return true and false values.

3. Using the methods you wrote for the above question, write a method that takes a Scanner as an input parameter and returns a String as a result. The method should print a prompt to the screen asking the user to enter a palindrome. It should then test the input. If it is not a palindrome, it should print an error message and continue asking for a palindrome until the user provides one. Once a palindrome has been input, the method should return it. In addition, write a main method that uses this method and displays the final palindrome to the screen.

4. Write a method named rowOfStars that takes a single integer parameter n and returns a String with that many stars in it. For example, calling the method with a value of 3 would cause the String "***" to be returned.

5. Using the method you wrote for the previous question, write a method that takes a single integer parameter n and prints a triangle of stars to the screen that has a height and base size equal to n. For example, calling the method with a value of 4 will produce the triangle:

*

**

***

Reference no: EM131590509

Questions Cloud

A role in the reengineering of health care : How does the nurse manager or leader play a role in the reengineering of health care?
Why is the declaration of war sometimes seen as relationship : Why is the declaration of war sometimes seen as a relationship of conflict between the two federal branches?
A criminals can be restored through community interactions : Do you think that criminals can be restored through community interactions. Considering the fact that recidivism rates
Account balance is zero immediately after last withdrawal : If the account balance is zero immediately after the last withdrawal, what is X?
Write a method that takes a string as input : Write a method that takes a String as input and returns the reverse of that String. Then write a second method that uses the first method
Compute the basic earnings per share : Required: Compute the basic earnings per share and the diluted earnings per share. The tax rate is 30%
An example of change was when hipaa became a regulation : The nursing profession can be of great influence in three crucial areas-practice, education, and leadership-as well as to collect better data on the health care
Discuss the concept of community policing : Discuss the concept of community policing and explain why this model is considered optimal for developing effective police relations
How did innovations in wmd influence changes in warfare : How did innovations in WMD influence changes in warfare and in terrorist actions globally? Have terrorists used such weapons in the past? Explain.

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