Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Questions : 1. Why is this saying Display() is unreachable? 2. How do I get it to continuously repeat itself until i exit out with

Questions :

1. Why is this saying Display() is unreachable?

2. How do I get it to continuously repeat itself until i exit out with 2?

3. and how do i add 2 to make it exit. Thank you.

package peopleinclass; import java.util.Scanner;

public class PeopleinClass { static Scanner get=new Scanner(System.in); static String yourName; static int studentNames = 0; static int answer = 1; public static void main(String[] args) {

getNames(); while(true) { if(answer == 1 ) { System.out.println("Would you like to add another student? 1 for yes 2 for no "); answer=get.nextInt(); get.nextLine(); System.out.println("Please enter another students name: "); yourName = get.nextLine();

} } Display(); }

public static String getNames() { System.out.println("Please enter your students name: "); yourName = get.nextLine(); return yourName; } public static void Display() { System.out.println("Below are the students in the class: "); System.out.println( studentNames ); } }

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago