Image one is my code, I wanted to make some change to the blue part's code.
The code I written in red(see image 1) is the method to check that an integer has exactly 5 digits is provided for you (fiveDigits). You just need to call it appropriately in your code(the part in blue square)! Notice that the fiveDigits method returns a boolean - think carefully about how you should use this return type to reprompt the user until they enter a valid zip code.
And I want the same output be like (see image 2)
for the invalid zip code part: I should only reprompt the user with the message "Invalid zip-code, enter valid zip-code: " until they enter a valid zip code. Similarly, if the user enters an invalid pain level, you should reprompt the user with the message "Invalid pain level, enter valid pain level (1-10): " until they enter a valid pain level. For example(image2)
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 6 images
But for the name == quit, you are still using the break, can you also change that one too?
We can't use "break" in this code, can you change to other ways to do it?
(maybe use if or if else or if else if)
plz provide a screenshot of the code and out put .
Thanks
Thank you, but we don't allowed to use the "break", is there any other way to do it? (Maybe use if or else if)?
also plz provide a screenshot of the code and output.
But for the name == quit, you are still using the break, can you also change that one too?
We can't use "break" in this code, can you change to other ways to do it?
(maybe use if or if else or if else if)
plz provide a screenshot of the code and out put .
Thanks
Thank you, but we don't allowed to use the "break", is there any other way to do it? (Maybe use if or else if)?
also plz provide a screenshot of the code and output.
- Give comment to explain the code. Write a program that calls these two methods as described below A void method that ask user to input an integer to be a parameter and prints following pattern. For example, the user entered 5 as input, the pattern will be: 5 4 3 2 1 5 4 3 2 5 4 3 5 4 5 b. A void method takes Sting as a parameter. Then print out all the vowels in the string. Example given below:arrow_forwardJavaarrow_forwardIn this programming question, you are required to implement five methods according to the following instructions. - When an integer has more than a certain number of digits, it is represented using scientific notation. The int type itself cannot be used to store numbers with more than 10 digits. In some cases, this may be inconvenient as people usually expect complete numbers and doing big integer computations are inevitable. This method takes two numbers as CharStacks numl and num2, and subtract the subtractBigInteger () number stored in num2 from the one stored in numl, ie., numl num2. To simply implementation, you can assume that the number stored in numl is no less than the number stored in num2. For example, when subtracting 181,749 from 314,739,847, the two stacks and the result stack would look like the following: '7' '3" low digit "1" high digit "8' 4" '5' '3' '5' '7 '8" '4' '0' high digit low digit '1' "8' '1' "R' numl num2 stackResult In this method, you are provided with a…arrow_forward
- This program will determine if a number is divisible by 5 or not. This should be a simple task by now, but this time you will use a static method to do the checking. The method should be called divFive and will take in one integer. The code inside your method will check to see if the number passed is evenly divisibly by 5. If it is, the method will return a boolean true. If not, a boolean false. (The return type will be boolean, not a String.) In your main method, you will ask the user for input, accept the input, and then call your divFive method, passing in the user’s integer. With the Boolean result that you get back from the divFive method, you should have code that will print “Divisible by 5” if a true is returned and “Not divisible by 5” if a false is returned. This program MUST have a try/catch block to: Catch wrong data types (input mismatch) Catch values 0 or less (custom exception) The try/catch block should go in your main method since this is where you are…arrow_forwardCan you help me code this?arrow_forwardPlease help me! I have a lot of mini problems. I'm not sure how to start After #6, I have other problems. Those are : 7.) Write a method that reads a one-line sentence as input and then displays the following response: If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word Yes. If the sentence ends with a question mark and the input contains an odd number of characters, display the word No. If the sentence ends with an exclamation point (!), display the word Wow. In all other cases, display the words You always say followed by the input string enclosed in quotes. Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a legitimate sentence. Notes: This code requires a three-way selection statement and…arrow_forward
- (b) A programmer would like to modify the StringAnalyzer class to limit the length of the large string that can be passed as input to countRepeat countRepeat. A call to countRepeat with a value of largest that is longer than the maximum length would return -1. The programmer would changes to the signature of the countRepeat method or overloading countRepeat. Write a description of how you would change the stringAnalyzer class in order to support this modification. Do not write the program code for thi Make sure to include the following in your response. • Identify any new or modified variables or methods. Describe, for each new or revised variable or method, how it would change or be implemented, including visibility and type 4. GENERATE ID QUESTION This question involves generating a String that will be used as an identifier. You will write the generateID metho public class Identifier /** Encodes a string as an integel and returns the encoded int value */ public static int…arrow_forwardThis is what I have so far I am trying to calculate the tax as the TaxPayer's income (returned by its getIncome method) times a corporate tax rate of 21% (0.21). This is what I have so far. I also would like to save the variable in a double named tax. I am having trouble figuring out to call the TaxPayers income to multiply it by the tax rate.arrow_forwardYou need prints the coefficient followed by "x^" and appended by the exponent. But with the following additional rules: o if the coefficient is 1, then it is not printed. o if the exponent is 1, then it is not printed ( the caret is not printed as Output Expected 4x^4 Output well).arrow_forward
- Problem: To write the JUnit test cases for our methods, you need to create two test methods: testLeapYear: This method should test if the isLeapYear method returns true for a given leap year. For example, you can choose the year 2020 and verify if the method returns true for it. If it does, the test will pass. If it doesn't, the test will fail. testNotLeapYear: This method should test if the isLeapYear method returns false for a given non-leap year. For example, you can choose the year 1900 and verify if the method returns false for it. If it does, the test will pass. If it doesn't, the test will fail. --------------------------------------------------------------------------------------------------------------------------------------------------------- import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; public class LeapYearTest { // Test case to check if a year is a leap year @Test public void testLeapYear() { //create…arrow_forwardIn 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_forwardYou will build a program to manage a race car in this assessment. The code will consist of a for-loop method that will run a car around a race track and cause “wear and tear” on the car. The car will perform x number of laps and will have to make pitstops when it either runs out of gas or needs a tire replacement. The for loop will be simple def wear_tires(car): tire -=1 def use_gas(car): gas -=1 c = Car() # You need to make this part for i in range(100): if the car needs a pitstop: perform pitstop else: wear_tires(c) use_gas(c) # Display the current cars wear in a much better format print(c.tire) print(c.gas) print(“Current Lap is: “ , i) For this task, you will have to use this for loop and build out the two methods in the main Python program. To use the above code, you must build two pieces of information. An abstract Vehicle class A Car class A RaceCar class Each with its methods and variables. This programming will involve using inheritance and abstraction to make a race car…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY