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)

 

 

1- import java.util.*;
2 public class Main
3- {
4
5
6
7
8
9
10
11
13
14
15
16
17
18
19
20
21
22
23
24-
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
}
public static void main(String[] args)
{
}
System.out.println("Hello! We value you and your time, so we will help\nyou prioritize which patients to see next!\nPlease answer the following questions about the next patient so\nwe can help you do
String name = "";
Scanner sc = new Scanner(System.in);
while (!name.equals("quit"))
{
}
System.out.print("Patient's name: ");
name = sc.next();
if(name.equals("quit"))
System.out.print("Patient's age: ");
int age sc.nextInt ();
System.out.print("Patient's zip code: ");
int zip sc.nextInt();
break;
while(String.valueof(zip).length() != 5)
System.out.print("Invalid zip code, enter valid zip code: ");
zip sc.nextInt ();
if(String.valueOf(zip).length() == 5)
}
System.out.print("Is our hospital \"in network\" for the patient's insurance? ");
String insurance sc.next();
{
break;
System.out.print("Patient pain level (1-10): ");
int pain sc.nextInt ();
while(pain < 1 || pain > 10)
System.out.print("Invalid pain level, enter valid pain level (1-10): ");
pain sc.nextInt ();
}
if (pain >= 1 && pain <= 10)
break;
System.out.print("Patient temperature (in degrees Fahrenheit): ");
double temperature sc.nextDouble();
public static boolean five Digits (int val) {
val= val / 10000;
if (val == 0) {
:
return false;
} else if (val / 10 == 0) {
return true
} else {
return false;
Transcribed Image Text:1- import java.util.*; 2 public class Main 3- { 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 20 21 22 23 24- 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 } public static void main(String[] args) { } System.out.println("Hello! We value you and your time, so we will help\nyou prioritize which patients to see next!\nPlease answer the following questions about the next patient so\nwe can help you do String name = ""; Scanner sc = new Scanner(System.in); while (!name.equals("quit")) { } System.out.print("Patient's name: "); name = sc.next(); if(name.equals("quit")) System.out.print("Patient's age: "); int age sc.nextInt (); System.out.print("Patient's zip code: "); int zip sc.nextInt(); break; while(String.valueof(zip).length() != 5) System.out.print("Invalid zip code, enter valid zip code: "); zip sc.nextInt (); if(String.valueOf(zip).length() == 5) } System.out.print("Is our hospital \"in network\" for the patient's insurance? "); String insurance sc.next(); { break; System.out.print("Patient pain level (1-10): "); int pain sc.nextInt (); while(pain < 1 || pain > 10) System.out.print("Invalid pain level, enter valid pain level (1-10): "); pain sc.nextInt (); } if (pain >= 1 && pain <= 10) break; System.out.print("Patient temperature (in degrees Fahrenheit): "); double temperature sc.nextDouble(); public static boolean five Digits (int val) { val= val / 10000; if (val == 0) { : return false; } else if (val / 10 == 0) { return true } else { return false;
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 I
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 I 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
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