#whenever I run my code it keeps saying " error: unreachable statement"

3 messages · Page 1 of 1 (latest)

sly viper
#

import java.util.Scanner;

public class Main {
public static void main(String args[])
{

   Scanner sc = new Scanner(System.in);
   do {
        System.out.print("Would you like to know your Total Quarterly Salary? Press 1 if yes or Press 2 if no! ");
        int ch = sc.nextInt(); 
        switch (ch)
        {
        case 1: 
        System.out.println ("Enter Quarter's Salary of Region 1: ");
        int regiona = sc.nextInt();
        System.out.println ("Enter Quarter's Salary of Region 2: ");
        int regionb = sc.nextInt();
        System.out.println ("Enter Quarter's Salary of Region 3: ");
        int regionc = sc.nextInt();
        int kys = regiona + regionb + regionc;
        System.out.println ("Your Total Quarterly Salary is " +kys+ "!");

        if (kys > 5000) {
        System.out.println ("This year's Quarterly Sales are greater than the previous sales.");
        } 
        else {
        System.out.println ("                       ");
        System.out.println ("This year's Quarterly Sales are lesser than the previous sales.");
        }
        break;
   }
   }

   while(true);
    {
        int ch2 = sc.nextInt();
        switch (ch2) 
        {
        case 2:
        System.out.println ("                       ");
        System.out.println ("***********************");
        System.out.println ("This program has ended!");
        break;
        default:
        System.out.println ("                       ");
        System.out.println ("***********************");
        System.out.println ("This program has ended!");
        }
    }    
    
}

}

bold garnetBOT
#

This post has been reserved for your question.

Hey @sly viper! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.