• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Need help on java

Jhayzone

Android Enthusiast
Oct 21, 2015
384
225
Hi guys! I'm having problem on using nested switch on my code can someone tell me what I'm doing wrong? I'm only using notepad on coding and jdk and cmd to compile the code since I can't be bother downloading netbeans.

Anyway, the error is "Orphaned Case"

import java.util.Scanner;
public class Jayson{
public static void main(String[]args){
Scanner a=new Scanner(System.in);

int [] Quantity, pro_Quantity;
int item, C_loop, i=0;

double [] Price, T_Price;
double TotalPrice;
String [] Product, item_Name;
string name;

//Product Declartion
Product[0] = "Banana";
Product[1] = "Apple";
Product[2] = "Melon";
Product[3] = "Grapes";
Product[4] = "Strawberry";
Product[5] = "Colgate";
Product[6] = "Safeguard";
Product[7] = "Dove";

//Quantity Declaration
Quantity[0] = 100;
Quantity[1] = 100;
Quantity[2] = 100;
Quantity[3] = 100;
Quantity[4] = 100;
Quantity[5] = 100;
Quantity[6] = 100;
Quantity[7] = 100;

//Price Declaration
Price[0] = 40;
Price[1] = 80;
Price[2] = 40;
Price[3] = 80;
Price[4] = 150;
Price[5] = 54;
Price[6] = 55;
Price[7] = 53;


System.out.println("|*********************************************|");
System.out.println("| ITEM | PRICE | QUANTITY |");
System.out.println("|*********************************************|");
System.out.println(" 1.) Banana | 40 | " + Quantity[0]);
System.out.println(" 2.) Apple | 80 | " + Quantity[1]);
System.out.println(" 3.) Melon | 40 | " + Quantity[2]);
System.out.println(" 4.) Grapes | 80 | " + Quantity[3]);
System.out.println(" 5.) Strawberry | 150 | " + Quantity[4]);
System.out.println(" 6.) Colgate | 54 | " + Quantity[5]);
System.out.println(" 7.) Safeguard | 55 | " + Quantity[6]);
System.out.println(" 8.) Dove | 53 | " + Quantity[7]);
System.out.println("|*********************************************|");

System.out.println("***************************");
System.out.println("Enter Customer Name: ");
name = a.nextLine();
System.out.println("Enter the number of the product that you want to purchase: ");
item = a.nextInt();
System.out.println("Enter quantity:");
pro_Quantity[0] = a.nextInt();
switch(item)
{
case 1:
item_Name[0] = Product[0];
Quantity[0] = Quantity[0] - pro_Quantity;
T_Price[0]=pro_Quantity*Price[0];
break;

case 2:
item_Name[0] = Product[1];
Quantity[1] = Quantity[1] - pro_Quantity;
T_Price[0]=pro_Quantity*Price[1];
break;

case 3:
item_Name[0] = Product[2];
Quantity[2] = Quantity[2] - pro_Quantity;
T_Price[0]=pro_Quantity*Price[2];
break;

case 4:
item_Name[0] = Product[3];
Quantity[3] = Quantity[3] - pro_Quantity;
T_Price[0]=pro_Quantity*Price[3];
break;

case 5:
item_Name[0] = Product[4];
Quantity[4] = Quantity[4] - pro_Quantity;
T_Price[0]=pro_Quantity*Price[4];
break;

case 6:
item_Name[0] = Product[5];
Quantity[5] = Quantity[5] - pro_Quantity;
T_Price[0]=pro_Quantity*Price[5];
break;

case 7:
item_Name[0] = Product[6];
Quantity[6] = Quantity[6] - pro_Quantity;
T_Price[0]=pro_Quantity*Price[6];
break;

case 8:
item_Name[0] = Product[7];
Quantity[7] = Quantity[7] - pro_Quantity;
T_Price[0]=pro_Quantity*Price[7];
break;

default:
System.out.println ("Invalid #, you're banned on this store!");
}

System.out.println ("Do you want to add more?");
System.out.println ("1='Yes' and 2='No'");
break;
//***************LOOP 1*******************************

swtich(C_loop);
{
case 1:

System.out.println("|*********************************************|");
System.out.println("| ITEM | PRICE | QUANTITY |");
System.out.println("|*********************************************|");
System.out.println(" 1.) Banana | 40 | " + Quantity[0]);
System.out.println(" 2.) Apple | 80 | " + Quantity[1]);
System.out.println(" 3.) Melon | 40 | " + Quantity[2]);
System.out.println(" 4.) Grapes | 80 | " + Quantity[3]);
System.out.println(" 5.) Strawberry | 150 | " + Quantity[4]);
System.out.println(" 6.) Colgate | 54 | " + Quantity[5]);
System.out.println(" 7.) Safeguard | 55 | " + Quantity[6]);
System.out.println(" 8.) Dove | 53 | " + Quantity[7]);
System.out.println("|*********************************************|");

System.out.println("***************************");
System.out.println("Enter Customer Name: ");
name = a.nextLine();
System.out.println("Enter the number of the product that you want to purchase: ");
item = a.nextInt();
System.out.println("Enter quantity:");
pro_Quantity[1] = a.nextInt();
switch(item)
{
case 1:
item_Name[1] = Product[0];
Quantity[0] = Quantity[0] - pro_Quantity;
T_Price[1]=pro_Quantity*Price[0];
break;

case 2:
item_Name[1] = Product[1];
Quantity[1] = Quantity[1] - pro_Quantity;
T_Price[1]=pro_Quantity*Price[1];
break;

case 3:
item_Name[1] = Product[2];
Quantity[2] = Quantity[2] - pro_Quantity;
T_Price[1]=pro_Quantity*Price[2];
break;

case 4:
item_Name[1] = Product[3];
Quantity[3] = Quantity[3] - pro_Quantity;
T_Price[1]=pro_Quantity*Price[3];
break;

case 5:
item_Name[1] = Product[4];
Quantity[4] = Quantity[4] - pro_Quantity;
T_Price[1]=pro_Quantity*Price[4];
break;

case 6:
item_Name[1] = Product[5];
Quantity[5] = Quantity[5] - pro_Quantity;
T_Price[1]=pro_Quantity*Price[5];
break;

case 7:
item_Name[1] = Product[6];
Quantity[6] = Quantity[6] - pro_Quantity;
T_Price[1]=pro_Quantity*Price[6];
break;

case 8:
item_Name[1] = Product[7];
Quantity[7] = Quantity[7] - pro_Quantity;
T_Price[1]=pro_Quantity*Price[7];
break;

default:
System.out.println ("Invalid #, you're banned on this store!");
}

System.out.println ("Do you want to add more?");
System.out.println ("1='Yes' and 2='No'");
break;
//***************LOOP 2*******************************

swtich(C_loop);
{
case 1:

System.out.println("|*********************************************|");
System.out.println("| ITEM | PRICE | QUANTITY |");
System.out.println("|*********************************************|");
System.out.println(" 1.) Banana | 40 | " + Quantity[0]);
System.out.println(" 2.) Apple | 80 | " + Quantity[1]);
System.out.println(" 3.) Melon | 40 | " + Quantity[2]);
System.out.println(" 4.) Grapes | 80 | " + Quantity[3]);
System.out.println(" 5.) Strawberry | 150 | " + Quantity[4]);
System.out.println(" 6.) Colgate | 54 | " + Quantity[5]);
System.out.println(" 7.) Safeguard | 55 | " + Quantity[6]);
System.out.println(" 8.) Dove | 53 | " + Quantity[7]);
System.out.println("|*********************************************|");

System.out.println("***************************");
System.out.println("Enter Customer Name: ");
name = a.nextLine();
System.out.println("Enter the number of the product that you want to purchase: ");
item = a.nextInt();
System.out.println("Enter quantity:");
pro_Quantity[2] = a.nextInt();
switch(item)
{
case 1:
item_Name[2] = Product[0];
Quantity[0] = Quantity[0] - pro_Quantity;
T_Price[2]=pro_Quantity*Price[0];
break;

case 2:
item_Name[2] = Product[1];
Quantity[1] = Quantity[1] - pro_Quantity;
T_Price[2]=pro_Quantity*Price[1];
break;

case 3:
item_Name[2] = Product[2];
Quantity[2] = Quantity[2] - pro_Quantity;
T_Price[2]=pro_Quantity*Price[2];
break;

case 4:
item_Name[2] = Product[3];
Quantity[3] = Quantity[3] - pro_Quantity;
T_Price[2]=pro_Quantity*Price[3];
break;

case 5:
item_Name[2] = Product[4];
Quantity[4] = Quantity[4] - pro_Quantity;
T_Price[2]=pro_Quantity*Price[4];
break;

case 6:
item_Name[2] = Product[5];
Quantity[5] = Quantity[5] - pro_Quantity;
T_Price[2]=pro_Quantity*Price[5];
break;

case 7:
item_Name[2] = Product[6];
Quantity[6] = Quantity[6] - pro_Quantity;
T_Price[2]=pro_Quantity*Price[6];
break;

case 8:
item_Name[2] = Product[7];
Quantity[7] = Quantity[7] - pro_Quantity;
T_Price[2]=pro_Quantity*Price[7];
break;

default:
System.out.println ("Invalid #, you're banned on this store!");
}

System.out.println ("Do you want to add more?");
System.out.println ("1='Yes' and 2='No'");
break;

//***************LOOP 3*******************************
swtich(C_loop);
{
case 1:

System.out.println("|*********************************************|");
System.out.println("| ITEM | PRICE | QUANTITY |");
System.out.println("|*********************************************|");
System.out.println(" 1.) Banana | 40 | " + Quantity[0]);
System.out.println(" 2.) Apple | 80 | " + Quantity[1]);
System.out.println(" 3.) Melon | 40 | " + Quantity[2]);
System.out.println(" 4.) Grapes | 80 | " + Quantity[3]);
System.out.println(" 5.) Strawberry | 150 | " + Quantity[4]);
System.out.println(" 6.) Colgate | 54 | " + Quantity[5]);
System.out.println(" 7.) Safeguard | 55 | " + Quantity[6]);
System.out.println(" 8.) Dove | 53 | " + Quantity[7]);
System.out.println("|*********************************************|");

System.out.println("***************************");
System.out.println("Enter Customer Name: ");
name = a.nextLine();
System.out.println("Enter the number of the product that you want to purchase: ");
item = a.nextInt();
System.out.println("Enter quantity:");
pro_Quantity[3] = a.nextInt();
switch(item)
{
case 1:
item_Name[3] = Product[0];
Quantity[0] = Quantity[0] - pro_Quantity;
T_Price[3]=pro_Quantity*Price[0];
break;

case 2:
item_Name[3] = Product[1];
Quantity[1] = Quantity[1] - pro_Quantity;
T_Price[3]=pro_Quantity*Price[1];
break;

case 3:
item_Name[3] = Product[2];
Quantity[2] = Quantity[2] - pro_Quantity;
T_Price[3]=pro_Quantity*Price[2];
break;

case 4:
item_Name[3] = Product[3];
Quantity[3] = Quantity[3] - pro_Quantity;
T_Price[3]=pro_Quantity*Price[3];
break;

case 5:
item_Name[3] = Product[4];
Quantity[4] = Quantity[4] - pro_Quantity;
T_Price[3]=pro_Quantity*Price[4];
break;

case 6:
item_Name[3] = Product[5];
Quantity[5] = Quantity[5] - pro_Quantity;
T_Price[3]=pro_Quantity*Price[5];
break;

case 7:
item_Name[3] = Product[6];
Quantity[6] = Quantity[6] - pro_Quantity;
T_Price[3]=pro_Quantity*Price[6];
break;

case 8:
item_Name[3] = Product[7];
Quantity[7] = Quantity[7] - pro_Quantity;
T_Price[3]=pro_Quantity*Price[7];
break;

default:
System.out.println ("Invalid #, you're banned on this store!");
}

System.out.println ("Do you want to add more?");
System.out.println ("1='Yes' and 2='No'");
break;

//***************LOOP 4*******************************
swtich(C_loop);
{
case 1:

System.out.println("|*********************************************|");
System.out.println("| ITEM | PRICE | QUANTITY |");
System.out.println("|*********************************************|");
System.out.println(" 1.) Banana | 40 | " + Quantity[0]);
System.out.println(" 2.) Apple | 80 | " + Quantity[1]);
System.out.println(" 3.) Melon | 40 | " + Quantity[2]);
System.out.println(" 4.) Grapes | 80 | " + Quantity[3]);
System.out.println(" 5.) Strawberry | 150 | " + Quantity[4]);
System.out.println(" 6.) Colgate | 54 | " + Quantity[5]);
System.out.println(" 7.) Safeguard | 55 | " + Quantity[6]);
System.out.println(" 8.) Dove | 53 | " + Quantity[7]);
System.out.println("|*********************************************|");

System.out.println("***************************");
System.out.println("Enter Customer Name: ");
name = a.nextLine();
System.out.println("Enter the number of the product that you want to purchase: ");
item = a.nextInt();
System.out.println("Enter quantity:");
pro_Quantity[4] = a.nextInt();
switch(item)
{
case 1:
item_Name[4] = Product[0];
Quantity[0] = Quantity[0] - pro_Quantity;
T_Price[4]=pro_Quantity*Price[0];
break;

case 2:
item_Name[4] = Product[1];
Quantity[1] = Quantity[1] - pro_Quantity;
T_Price[4]=pro_Quantity*Price[1];
break;

case 3:
item_Name[4] = Product[2];
Quantity[2] = Quantity[2] - pro_Quantity;
T_Price[4]=pro_Quantity*Price[2];
break;

case 4:
item_Name[4] = Product[3];
Quantity[3] = Quantity[3] - pro_Quantity;
T_Price[4]=pro_Quantity*Price[3];
break;

case 5:
item_Name[4] = Product[4];
Quantity[4] = Quantity[4] - pro_Quantity;
T_Price[4]=pro_Quantity*Price[4];
break;

case 6:
item_Name[4] = Product[5];
Quantity[5] = Quantity[5] - pro_Quantity;
T_Price[4]=pro_Quantity*Price[5];
break;

case 7:
item_Name[4] = Product[6];
Quantity[6] = Quantity[6] - pro_Quantity;
T_Price[4]=pro_Quantity*Price[6];
break;

case 8:
item_Name[4] = Product[7];
Quantity[7] = Quantity[7] - pro_Quantity;
T_Price[4]=pro_Quantity*Price[7];
break;

default:
System.out.println ("Invalid #, you're banned on this store!");
}

System.out.println ("Do you want to add more?");
System.out.println ("1='Yes' and 2='No'");
break;

//***************LOOP 5*******************************
swtich(C_loop);
{
case 1:

System.out.println("|*********************************************|");
System.out.println("| ITEM | PRICE | QUANTITY |");
System.out.println("|*********************************************|");
System.out.println(" 1.) Banana | 40 | " + Quantity[0]);
System.out.println(" 2.) Apple | 80 | " + Quantity[1]);
System.out.println(" 3.) Melon | 40 | " + Quantity[2]);
System.out.println(" 4.) Grapes | 80 | " + Quantity[3]);
System.out.println(" 5.) Strawberry | 150 | " + Quantity[4]);
System.out.println(" 6.) Colgate | 54 | " + Quantity[5]);
System.out.println(" 7.) Safeguard | 55 | " + Quantity[6]);
System.out.println(" 8.) Dove | 53 | " + Quantity[7]);
System.out.println("|*********************************************|");

System.out.println("***************************");
System.out.println("Enter Customer Name: ");
name = a.nextLine();
System.out.println("Enter the number of the product that you want to purchase: ");
item = a.nextInt();
System.out.println("Enter quantity:");
pro_Quantity[5] = a.nextInt();
switch(item)
{
case 1:
item_Name[5] = Product[0];
Quantity[0] = Quantity[0] - pro_Quantity;
T_Price[5]=pro_Quantity*Price[0];
break;

case 2:
item_Name[5] = Product[1];
Quantity[1] = Quantity[1] - pro_Quantity;
T_Price[5]=pro_Quantity*Price[1];
break;

case 3:
item_Name[5] = Product[2];
Quantity[2] = Quantity[2] - pro_Quantity;
T_Price[5]=pro_Quantity*Price[2];
break;

case 4:
item_Name[5] = Product[3];
Quantity[3] = Quantity[3] - pro_Quantity;
T_Price[5]=pro_Quantity*Price[3];
break;

case 5:
item_Name[5] = Product[4];
Quantity[4] = Quantity[4] - pro_Quantity;
T_Price[5]=pro_Quantity*Price[4];
break;

case 6:
item_Name[5] = Product[5];
Quantity[5] = Quantity[5] - pro_Quantity;
T_Price[5]=pro_Quantity*Price[5];
break;

case 7:
item_Name[5] = Product[6];
Quantity[6] = Quantity[6] - pro_Quantity;
T_Price[5]=pro_Quantity*Price[6];
break;

case 8:
item_Name[5] = Product[7];
Quantity[7] = Quantity[7] - pro_Quantity;
T_Price[5]=pro_Quantity*Price[7];
break;

default:
System.out.println ("Invalid #, you're banned on this store!");
}

System.out.println ("Do you want to add more?");
System.out.println ("1='Yes' and 2='No'");
break;

//***************LOOP 6*******************************
swtich(C_loop);
{
case 1:

System.out.println("|*********************************************|");
System.out.println("| ITEM | PRICE | QUANTITY |");
System.out.println("|*********************************************|");
System.out.println(" 1.) Banana | 40 | " + Quantity[0]);
System.out.println(" 2.) Apple | 80 | " + Quantity[1]);
System.out.println(" 3.) Melon | 40 | " + Quantity[2]);
System.out.println(" 4.) Grapes | 80 | " + Quantity[3]);
System.out.println(" 5.) Strawberry | 150 | " + Quantity[4]);
System.out.println(" 6.) Colgate | 54 | " + Quantity[5]);
System.out.println(" 7.) Safeguard | 55 | " + Quantity[6]);
System.out.println(" 8.) Dove | 53 | " + Quantity[7]);
System.out.println("|*********************************************|");

System.out.println("***************************");
System.out.println("Enter Customer Name: ");
name = a.nextLine();
System.out.println("Enter the number of the product that you want to purchase: ");
item = a.nextInt();
System.out.println("Enter quantity:");
pro_Quantity[6] = a.nextInt();
switch(item)
{
case 1:
item_Name[6] = Product[0];
Quantity[0] = Quantity[0] - pro_Quantity;
T_Price[6]=pro_Quantity*Price[0];
break;

case 2:
item_Name[6] = Product[1];
Quantity[1] = Quantity[1] - pro_Quantity;
T_Price[6]=pro_Quantity*Price[1];
break;

case 3:
item_Name[6] = Product[2];
Quantity[2] = Quantity[2] - pro_Quantity;
T_Price[6]=pro_Quantity*Price[2];
break;

case 4:
item_Name[6] = Product[3];
Quantity[3] = Quantity[3] - pro_Quantity;
T_Price[6]=pro_Quantity*Price[3];
break;

case 5:
item_Name[6] = Product[4];
Quantity[4] = Quantity[4] - pro_Quantity;
T_Price[6]=pro_Quantity*Price[4];
break;

case 6:
item_Name[6] = Product[5];
Quantity[5] = Quantity[5] - pro_Quantity;
T_Price[6]=pro_Quantity*Price[5];
break;

case 7:
item_Name[6] = Product[6];
Quantity[6] = Quantity[6] - pro_Quantity;
T_Price[6]=pro_Quantity*Price[6];
break;

case 8:
item_Name[6] = Product[7];
Quantity[7] = Quantity[7] - pro_Quantity;
T_Price[6]=pro_Quantity*Price[7];
break;

default:
System.out.println ("Invalid #, you're banned on this store!");

System.out.println ("Do you want to add more?");
System.out.println ("1='Yes' and 2='No'");
break;

//***************LOOP 7*******************************
swtich(C_loop);
{
case 1:

System.out.println("|*********************************************|");
System.out.println("| ITEM | PRICE | QUANTITY |");
System.out.println("|*********************************************|");
System.out.println(" 1.) Banana | 40 | " + Quantity[0]);
System.out.println(" 2.) Apple | 80 | " + Quantity[1]);
System.out.println(" 3.) Melon | 40 | " + Quantity[2]);
System.out.println(" 4.) Grapes | 80 | " + Quantity[3]);
System.out.println(" 5.) Strawberry | 150 | " + Quantity[4]);
System.out.println(" 6.) Colgate | 54 | " + Quantity[5]);
System.out.println(" 7.) Safeguard | 55 | " + Quantity[6]);
System.out.println(" 8.) Dove | 53 | " + Quantity[7]);
System.out.println("|*********************************************|");

System.out.println("***************************");
System.out.println("Enter Customer Name: ");
name = a.nextLine();
System.out.println("Enter the number of the product that you want to purchase: ");
item = a.nextInt();
System.out.println("Enter quantity:");
pro_Quantity[7] = a.nextInt();
switch(item)
{
case 1:
item_Name[7] = Product[0];
Quantity[0] = Quantity[0] - pro_Quantity;
T_Price[7]=pro_Quantity*Price[0];
break;

case 2:
item_Name[7] = Product[1];
Quantity[1] = Quantity[1] - pro_Quantity;
T_Price[7]=pro_Quantity*Price[1];
break;

case 3:
item_Name[7] = Product[2];
Quantity[2] = Quantity[2] - pro_Quantity;
T_Price[7]=pro_Quantity*Price[2];
break;

case 4:
item_Name[7] = Product[3];
Quantity[3] = Quantity[3] - pro_Quantity;
T_Price[7]=pro_Quantity*Price[3];
break;

case 5:
item_Name[7] = Product[4];
Quantity[4] = Quantity[4] - pro_Quantity;
T_Price[7]=pro_Quantity*Price[4];
break;

case 6:
item_Name[7] = Product[5];
Quantity[5] = Quantity[5] - pro_Quantity;
T_Price[7]=pro_Quantity*Price[5];
break;

case 7:
item_Name[7] = Product[6];
Quantity[6] = Quantity[6] - pro_Quantity;
T_Price[7]=pro_Quantity*Price[6];
break;

case 8:
item_Name[7] = Product[7];
Quantity[7] = Quantity[7] - pro_Quantity;
T_Price[7]=pro_Quantity*Price[7];
break;

default:
System.out.println ("Invalid #, you're banned on this store!");
}


System.out.println("Customer Name:"+name);
System.out.println(" " + item_Name[0] + pro_Quantity[0] +"pc/s = " + T_Price[0]);
System.out.println(" " + item_Name[1] + pro_Quantity[1] +"pc/s = " + T_Price[1]);
System.out.println(" " + item_Name[2] + pro_Quantity[2] +"pc/s = " + T_Price[2]);
System.out.println(" " + item_Name[3] + pro_Quantity[3] +"pc/s = " + T_Price[3]);
System.out.println(" " + item_Name[4] + pro_Quantity[4] +"pc/s = " + T_Price[4]);
System.out.println(" " + item_Name[5] + pro_Quantity[5] +"pc/s = " + T_Price[5]);
System.out.println(" " + item_Name[6] + pro_Quantity[6] +"pc/s = " + T_Price[6]);
System.out.println(" " + item_Name[7] + pro_Quantity[7] +"pc/s = " + T_Price[7]);
TotalPrice=T_Price[0]+T_Price[1]+T_Price[2]+T_Price[3]+T_Price[4]+T_Price[5]+T_Price[6]+T_Price[7];
System.out.println("Total Price:" + TotalPrice);
break;



case 2:
System.out.println("Customer Name:"+name);
System.out.println(" " + item_Name[0] + pro_Quantity[0] +"pc/s = " + T_Price[0]);
System.out.println(" " + item_Name[1] + pro_Quantity[1] +"pc/s = " + T_Price[1]);
System.out.println(" " + item_Name[2] + pro_Quantity[2] +"pc/s = " + T_Price[2]);
System.out.println(" " + item_Name[3] + pro_Quantity[3] +"pc/s = " + T_Price[3]);
System.out.println(" " + item_Name[4] + pro_Quantity[4] +"pc/s = " + T_Price[4]);
System.out.println(" " + item_Name[5] + pro_Quantity[5] +"pc/s = " + T_Price[5]);
System.out.println(" " + item_Name[6] + pro_Quantity[6] +"pc/s = " + T_Price[6]);
TotalPrice=T_Price[0]+T_Price[1]+T_Price[2]+T_Price[3]+T_Price[4]+T_Price[5]+T_Price[6];
System.out.println("Total Price:" + TotalPrice);
break;
}

case 2:
System.out.println("Customer Name:"+name);
System.out.println(" " + item_Name[0] + pro_Quantity[0] +"pc/s = " + T_Price[0]);
System.out.println(" " + item_Name[1] + pro_Quantity[1] +"pc/s = " + T_Price[1]);
System.out.println(" " + item_Name[2] + pro_Quantity[2] +"pc/s = " + T_Price[2]);
System.out.println(" " + item_Name[3] + pro_Quantity[3] +"pc/s = " + T_Price[3]);
System.out.println(" " + item_Name[4] + pro_Quantity[4] +"pc/s = " + T_Price[4]);
System.out.println(" " + item_Name[5] + pro_Quantity[5] +"pc/s = " + T_Price[5]);
TotalPrice=T_Price[0]+T_Price[1]+T_Price[2]+T_Price[3]+T_Price[4]+T_Price[5];
System.out.println("Total Price:" + TotalPrice);
break;
}

case 2:
System.out.println("Customer Name:"+name);
System.out.println(" " + item_Name[0] + pro_Quantity[0] +"pc/s = " + T_Price[0]);
System.out.println(" " + item_Name[1] + pro_Quantity[1] +"pc/s = " + T_Price[1]);
System.out.println(" " + item_Name[2] + pro_Quantity[2] +"pc/s = " + T_Price[2]);
System.out.println(" " + item_Name[3] + pro_Quantity[3] +"pc/s = " + T_Price[3]);
System.out.println(" " + item_Name[4] + pro_Quantity[4] +"pc/s = " + T_Price[4]);
TotalPrice=T_Price[0]+T_Price[1]+T_Price[2]+T_Price[3]+T_Price[4];
System.out.println("Total Price:" + TotalPrice);
break;
}

case 2:
System.out.println("Customer Name:"+name);
System.out.println(" " + item_Name[0] + pro_Quantity[0] +"pc/s = " + T_Price[0]);
System.out.println(" " + item_Name[1] + pro_Quantity[1] +"pc/s = " + T_Price[1]);
System.out.println(" " + item_Name[2] + pro_Quantity[2] +"pc/s = " + T_Price[2]);
System.out.println(" " + item_Name[3] + pro_Quantity[3] +"pc/s = " + T_Price[3]);
TotalPrice=T_Price[0]+T_Price[1]+T_Price[2]+T_Price[3];
System.out.println("Total Price:" + TotalPrice);
break;
}

case 2:
System.out.println("Customer Name:"+name);
System.out.println(" " + item_Name[0] + pro_Quantity[0] +"pc/s = " + T_Price[0]);
System.out.println(" " + item_Name[1] + pro_Quantity[1] +"pc/s = " + T_Price[1]);
System.out.println(" " + item_Name[2] + pro_Quantity[2] +"pc/s = " + T_Price[2]);
TotalPrice=T_Price[0]+T_Price[1]+T_Price[2];
System.out.println("Total Price:" + TotalPrice);
break;
}

case 2:
System.out.println("Customer Name:"+name);
System.out.println(" " + item_Name[0] + pro_Quantity[0] +"pc/s = " + T_Price[0]);
System.out.println(" " + item_Name[1] + pro_Quantity[1] +"pc/s = " + T_Price[1]);
TotalPrice=T_Price[0]+T_Price[1];
System.out.println("Total Price:" + TotalPrice);
break;
}

case 2:
System.out.println("Customer Name:"+name);
System.out.println(" " + item_Name[0] + pro_Quantity[0] +"pc/s = " + T_Price[0]);
System.out.println("Total Price:" + T_Price[0]);
break;
}
}
}



Yeah I know that looping will certainly make this code smaller but I'm a masochist. :p
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones