Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Java] Code below keeps printing out a new line. public int prompt_Zip() { System.out.println(Zip:); while(!scan.hasNextInt()) { System.out.println(Wrong input! + Zip: ); scan.next(); } int

[Java]

Code below keeps printing out a new line.

public int prompt_Zip() { System.out.println("Zip:"); while(!scan.hasNextInt()) { System.out.println("Wrong input! " + "Zip: "); scan.next(); } int zip = Integer.parseInt(scan.next()); return zip; } public String prompt_Telephone() { System.out.println("Phone Number(xxx-xxx-xxxx):"); while(scan.next().contains("[A-Za-z]+")) { System.out.println("Wrong input! " + "Phone Number(xxx-xxx-xxxx):"); scan.next(); } String phone = scan.next(); ; return phone; } public String prompt_Email() { System.out.println("Email:"); while(!scan.next().contains("@")) { System.out.println("Wrong input! " + "Email:"); } String email = scan.next(); ; return email; }

The output I want is

Zip:

12345

Phone Number(xxx-xxx-xxxx):

123-456-7890

Email:

abc@(domain)

But what I have rn is

Zip:

12345

Phone Number(xxx-xxx-xxxx):

123-456-7890

(blank here. Have to enter twice to give email address)

Email:

abc@(domain)

(Also blank here)

Please fix the code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions