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)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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)

 

 

The image displays a Java code snippet designed for capturing and validating patient information. Here's the transcription and explanation:

---

### Java Code for Patient Information Collection

**Imports and Class Declaration:**
```java
import java.util.*;
public class Main {
```

**Main Method:**
Responsible for collecting user input and validating the data.

```java
public static void main(String[] args) {
```

**Variables:**
- `String name`: Stores the patient's name.
- `int age`: Stores the patient's age.
- `int zip`: Stores the patient's zip code.
- `String insurance`: Stores the patient's insurance information.
- `int pain`: Stores the patient's pain level.
- `double temperature`: Stores the patient's temperature.

**Input and Validation Logic:**
- Prompts for the patient's name, age, zip code, insurance status, pain level, and temperature.

1. **Patient Name:**
   ```java
   System.out.print("Patient's name: ");
   ```

2. **Patient Age:**
   ```java
   System.out.print("Patient's age: ");
   ```

3. **Zip Code Validation:**
   Ensures the zip code entered is five digits long.
   ```java
   System.out.print("Patient's zip code: ");
   int zip = sc.nextInt();
   while (String.valueOf(zip).length() != 5) {
       System.out.print("Invalid zip code, enter valid zip code: ");
       zip = sc.nextInt();
   }
   ```

4. **Insurance Information:**
   ```java
   System.out.print("Is our hospital \"in network\" for the patient's insurance? ");
   ```

5. **Pain Level Validation:**
   Ensures the pain level is between 1 and 10.
   ```java
   System.out.print("Patient pain level (1-10): ");
   while (pain < 1 || pain > 10) {
       System.out.print("Invalid pain level, enter valid pain level (1-10): ");
       pain = sc.nextInt();
   }
   ```

6. **Patient Temperature:**
   ```java
   System.out.print("Patient temperature (in degrees Fahrenheit): ");
   ```

**Zip Code Verification Method:**
Located to the right in red, this method checks if a given integer is a five-digit number using a mathematical approach.

```java
public static boolean fiveDigits(int val) {
    val = val /
Transcribed Image Text:The image displays a Java code snippet designed for capturing and validating patient information. Here's the transcription and explanation: --- ### Java Code for Patient Information Collection **Imports and Class Declaration:** ```java import java.util.*; public class Main { ``` **Main Method:** Responsible for collecting user input and validating the data. ```java public static void main(String[] args) { ``` **Variables:** - `String name`: Stores the patient's name. - `int age`: Stores the patient's age. - `int zip`: Stores the patient's zip code. - `String insurance`: Stores the patient's insurance information. - `int pain`: Stores the patient's pain level. - `double temperature`: Stores the patient's temperature. **Input and Validation Logic:** - Prompts for the patient's name, age, zip code, insurance status, pain level, and temperature. 1. **Patient Name:** ```java System.out.print("Patient's name: "); ``` 2. **Patient Age:** ```java System.out.print("Patient's age: "); ``` 3. **Zip Code Validation:** Ensures the zip code entered is five digits long. ```java System.out.print("Patient's zip code: "); int zip = sc.nextInt(); while (String.valueOf(zip).length() != 5) { System.out.print("Invalid zip code, enter valid zip code: "); zip = sc.nextInt(); } ``` 4. **Insurance Information:** ```java System.out.print("Is our hospital \"in network\" for the patient's insurance? "); ``` 5. **Pain Level Validation:** Ensures the pain level is between 1 and 10. ```java System.out.print("Patient pain level (1-10): "); while (pain < 1 || pain > 10) { System.out.print("Invalid pain level, enter valid pain level (1-10): "); pain = sc.nextInt(); } ``` 6. **Patient Temperature:** ```java System.out.print("Patient temperature (in degrees Fahrenheit): "); ``` **Zip Code Verification Method:** Located to the right in red, this method checks if a given integer is a five-digit number using a mathematical approach. ```java public static boolean fiveDigits(int val) { val = val /
Hello! We value you and your time, so we will help you prioritize which patients to see next! Please answer the following questions about the next patient so we can help you do your best work :)

Please enter the next patient's name or "quit" to end the program.
- Patient's name: Issa
- Patient age: 14
- Patient zip code: 998
  - Invalid zip code, enter valid zip code: 1
  - Invalid zip code, enter valid zip code: 715498
  - Invalid zip code, enter valid zip code: 66548
- Is our hospital "in network" for the patient's insurance? no
- Patient pain level (1-10): -8
  - Invalid pain level, enter valid pain level (1-10): 22
  - Invalid pain level, enter valid pain level (1-10): 0
  - Invalid pain level, enter valid pain level (1-10): 3
- Patient temperature (in degrees Fahrenheit): 97.9
Transcribed Image Text:Hello! We value you and your time, so we will help you prioritize which patients to see next! Please answer the following questions about the next patient so we can help you do your best work :) Please enter the next patient's name or "quit" to end the program. - Patient's name: Issa - Patient age: 14 - Patient zip code: 998 - Invalid zip code, enter valid zip code: 1 - Invalid zip code, enter valid zip code: 715498 - Invalid zip code, enter valid zip code: 66548 - Is our hospital "in network" for the patient's insurance? no - Patient pain level (1-10): -8 - Invalid pain level, enter valid pain level (1-10): 22 - Invalid pain level, enter valid pain level (1-10): 0 - Invalid pain level, enter valid pain level (1-10): 3 - Patient temperature (in degrees Fahrenheit): 97.9
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

But for the name == quit, you are still using the break, can you also change that one too?

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

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 

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

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.

Solution
Bartleby Expert
SEE SOLUTION
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY