Category(elec)=phone=$130, phone2=$200, tablet=$120
Category(home)=soap=$10, hair brush=$5, lotion=$16
Write a mini java program the ask users to select one item from each categories and calculate the total.
Print(‘enter your name?
Enter address;
name, Thank You for Shopping with us
your items are; items name and price
your total is:
Your items will arrive in x days at your address;………….address entered above
****As short as possible, using for or while loops Thanks
I use while loop for continue your code and use switch case for other task
Code:
import java.util.*;
class HomeworkLib_items
{
public static void main(String arg[])
{
int total=0;
char c;
do{
Scanner ob = new
Scanner(System.in);
System.out.println("Enter Your
name:");
String name = ob.nextLine();
System.out.println("********************************");
System.out.println("Choose Any Item
from Given Category 1");
int ch,ivalue1=0,ivalue2=0;
String iname1="",iname2="";
System.out.println("1.Phone1\n2.Phone2\n3.Tablet\n");
ch = ob.nextInt();
switch(ch)
{
case
1: iname1="Phone1";
ivalue1=130;
total+=130;
break;
case
2: iname1="Phone2";
ivalue1=200;
total+=200;
break;
case
3: iname1="Tablet";
ivalue1=120;
total+=120;
break;
}
System.out.println("********************************");
System.out.println("Choose Any Item
from Given Category 2");
int ch1;
System.out.println("1.Shop\n2.Hair
Brush\n3.Lotion\n");
ch1 = ob.nextInt();
switch(ch1)
{
case
1: iname2="Shop";
ivalue2=10;
total+=10;
break;
case
2: iname2="Hair Brush";
ivalue2=5;
total+=5;
break;
case
3: iname2="Lotion";
ivalue2=16;
total+=16;
break;
}
System.out.println("********************************");
System.out.println("**************BILL**************");
System.out.println("Welcome
"+name);
System.out.println("***********Your
Items***********");
System.out.println("Items\t\tValue");
System.out.println(iname1+"\t\t"+ivalue1+"$");
System.out.println(iname2+"\t\t"+ivalue2+"$");
System.out.println("Your
Total:"+total+"$");
System.out.println("*******Thanks
For Shopping******");
System.out.println("********************************");
System.out.println("Want to Shop
More:(Y/N)");
c = ob.next().charAt(0);
}
while(c == 'Y');
}
}
Output:

Category(elec)=phone=$130, phone2=$200, tablet=$120 Category(home)=soap=$10, hair brush=$5, lotion=$16 Write a mini java program the ask users to...