Concept explainers
Modify your printDetai 1 s method to include printing the reference number. However, the method should print the reference number only if it has been set-that is, if the refNumber string has a non-zero length. If it has not been set, then print the string "ZZZ" instead. Hint: Use a conditional statement whose test calls the 1ength method on the refNumber string.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Database Concepts (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Python (4th Edition)
Electric Circuits. (11th Edition)
- In this assignment you will demonstrate your knowledge of debugging by fixing the errors you find in the program below. Fix the code, and paste it in this document, along with the list of the problems you fixed.This example allows the user to display the string for the day of the week. For example, if the user passed the integer 1, the method will return the string Sunday. If the user passed the integer 2, the method will return Monday. This code has both syntax errors and logic errors. Hint: There are two logic errors to find and fix (in addition to the syntax errors).Inport daysAndDates.DaysOfWeek;public class TestDaysOfWeek {public static void main(String[] args) {System.out.println("Days Of week: ");for (int i = 0;i < 8;i++) {System.out.println("Number: " + i + "\tDay Of Week: " + DaysOfWeek.DayOfWeekStr(i) )}}}package daysAndDatespublic class DaysOfWeek {public static String DayOfWeekStr(int NumberOfDay) {String dayStr = ""switch (NumberOfDay) {case 1:dayStr =…arrow_forwardWrite a method isPalidrome(String arg) that determines if a String is palindrome or not. Palindrome is when a String remains the same after reversing. The method should return boolean typeWrite a method isPalidrome(String arg) that determines if a String is palindrome or not. Palindrome is when a String remains the same after reversing. The method should return boolean typearrow_forwardWrite a method that accepts a String object as an argument and displays its contents backward.For instance, if the string argument is “gravity” the method should display -“ytivarg”.Demonstrate the method in a program that asks the user to input a string and then passes itto the method.arrow_forward
- note: You can easily replace a portion of text within a String using the String method "replace()". For example: String svar = "raspberry jam"; svar = svar.replace("jam", "pie"); System.out.println(svar); will print out: raspberry pie A photographer is organizing a photo collection about the national parks in the US and would like to annotate the information about each of the photos into a separate set of files. Write a program that reads the name of a text file containing a list of photo file names. The program then reads the photo file names from the text file, replaces the "_photo.jpg" portion of the file names with "_info.txt", and outputs the modified file names. Assume the unchanged portion of the photo file names contains only letters and numbers, and the text file stores one photo file name per line. If the text file is empty, the program produces no output.arrow_forwardWrite a method that counts the number of letters ina string using the following header:public static int countLetters(String s)Write a test program that prompts the user to enter a string and displays the numberof letters in the string.arrow_forwardCode in task2 () method as below. Using the String format method just once, display the integer values 1, 10, 100, 1000 each on its own line right justified. The values must not be hard-coded. Example of the output as below. 1 10 100 1000 Hints: Inserting the character sequence \n in a String embeds a 'line feed' (new line - similar to pressing ENTER when typing words in Notepad) in the string e.g. " linel\nline2"arrow_forward
- Part I Write a method that takes two parameters: integer n, char operation. If the given operation parameter is '+', then sum all numbers until n, otherwise multiply all numbers until n. Part II Write a method that prints a menu as given below and asks the user to input a value. If the value given by user is 'r' then repeat the menu. If the value given by user is 'e' then stop the code. [r]epeat menu [e]xit Enter an option: Part III Write a method that takes four integer parameters: æl, y1, x2 and y2. The method calcu- lates the distance between two points which theirs coordinate are given by the parameters. Note: Do not compress your files, submit only java files. Note: Do not forget to justify your answers with comments.arrow_forwardQuestion (1): Define the ReplaceAll method, its idea to search for partial text (word or phrase) specific and switch to another part. When you call the method, we must pass three texts. The first represents a plain text, the second represents the partial that we want to search for, and the third represents the partial that we want to replace with the second partial place. If the user click enter without writing a string, the program shows a message “There is no text!". See examples to get the idea. [5 Marks] Ехample 1: Enter your text: I am learning C++. I am writing C++ code. I like C++. Enter the word you want to replace: C++ Enter the word you want to replace with: Java Before: I am learning C++. I am writing C++ code. I like C++. After: I am learning Java. I am writing Java code. I like Java. Ехample 2: Enter your text: There is no text!arrow_forwardWrite a code snippet to prompt a user to enter two words.Then, pass these values as parameters in a method called checkSimilarities.Use this method to check if both words have the same number of upper and lowercase letters.Return true if both words contain the same amount of upper and lowercase letters, false if not.Print the results.*/ /*arrow_forward
- You are given two strings, pattern and value. The pattern string consists ofjust the letters a and b, describing a pattern within a string. For example, the string catcatgocatgo matches the pattern aabab (where cat is a and go is b). It also matches patterns like a, ab, and b. Write a method to determine if value matches pattern.arrow_forwardPrompt for the user to enter their name. Print out their name forwards, backwards, vertically-forwards and vertically-backwards. You will need to declare a String variable, use Scanner to get input of a String, call a String method to isolate one letter and create a loop that traverses the name forwards and backwards. Sample Output: Enter your name: Florene Florene enerolF F l o r e n e e n e r o l F HINTS: Scanner input = new Scanner(System.in); String myName = input.nextLine(); // input is a Scanner object int len = myName.length() // len is the number of characters System.out.println (myName.substring(len-1, len)); // prints last letter I need help with coding the name "Pooja" vertically-forwards and vertically-backwards in java. If you could show me what codes to type in, that would be great. Thank you!arrow_forwardWrite a method called upper that takes a lowercase character as a parameter and converts the character to uppercase and returns it without using String’s toUpperCase() method. public char upper(char lowerChar){ Question 26 options:arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT