import java.io.*;
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class finaLProject {
public static void main(String[] args) throws IOException, FileNotFoundException {{
// TODO Auto-generated method stub
String str,strage,name,address,gender,quantity,product, amountRecieve;
String Brand,model;
char ch,ch1,ch2,ch3,ch4,ch5;
int age,price;
int priceInt=0,quantityInt,totalamount;
PrintWriter inFile=new PrintWriter(new FileWriter("C:\\Users\\user\\Documents\\inCoDer.tx t",true));
do{
str= JOptionPane.showInputDialog(null,""
+ "\nR - Register"
+ "\nP - Purchase Item "
+ "\nI - Informantion of your Data"
+ "\nE - exit","Please Make a Choice",JOptionPane.PLAIN_MESSAGE+JOptionPane.OK_O PTION);
boolean exit=true;
ch=str.charAt(0);
Character.toLowerCase(ch);
switch(ch){
case 'r':
case 'R':{
name=JOptionPane.showInputDialog(null,"Name: "," Register ",JOptionPane.PLAIN_MESSAGE+JOptionPane.OK_OPTION) ;
strage=JOptionPane.showInputDialog(null,"Age: "," Register ",JOptionPane.PLAIN_MESSAGE+JOptionPane.OK_OPTION) ;
age= Integer.parseInt(strage);
address=JOptionPane.showInputDialog(null,"Address: "," Register",JOptionPane.PLAIN_MESSAGE+JOptionPane.OK _OPTION);
gender=JOptionPane.showInputDialog(null,"Gender: "," Register",JOptionPane.PLAIN_MESSAGE+JOptionPane.OK _OPTION);
switch (ch){
case 'P' :
case 'p':{
str=JOptionPane.showInputDialog(null, " PRODUCT\n"
+ "[C]: Cellphone\n"
+ "[L]: Laptop\n"
+ "[T]: Tablet\n");
break;}
default:
JOptionPane.showMessageDialog(null,"Invalid Choice:","Please try Again",JOptionPane.WARNING_MESSAGE+JOptionPane.OK_ OPTION);
} break;
boolean exit1=true;
ch1 = str.charAt(0);
Character.toLowerCase(ch1);
switch (ch1){
case 'c':
case 'C':{
product=JOptionPane.showInputDialog(null,"List of Cellphone \n"
+" Brand Medel Price\n"
+ "[N]: Nokia X-men $399\n"
+ "[S]: Samsung Galactic $450\n"
+ "[L]: Lenovo Mayon $350\n\n"
+"Add to Puschase Item",JOptionPane.WARNING_MESSAGE+JOptionPane.OK_O PTION);
}break;
default:
JOptionPane.showMessageDialog(null,"Invalid Choice:","Please try Again",JOptionPane.WARNING_MESSAGE+JOptionPane.OK_ OPTION);
}break;
boolean exit2=true;
ch2 = str.charAt(0);
Character.toLowerCase(ch1);
switch(ch2){
case'N':
case 'n':{
JOptionPane.showMessageDialog(null,"This will be added in your Information\n"
+ "\nBrand: Nokia\nModel: X-men\nPrice: $399");
Brand="Nokia";
model="X-men";
priceInt=399;
break;}
case 'S':
case's':{
JOptionPane.showMessageDialog(null,"This will be added in your Information\n"
+ "\nBrand: Samsung\nModel: Galactic\nPrice: $450");
Brand="SAMSUNG";
model="Galactic";
price=450;
break;}
case 'L':
case'l':{
JOptionPane.showMessageDialog(null,"This will be added in your Information\n"
+ "\nBrand: Lenovo\nModel: Mayon\nPrice: $350");
Brand="Lenovo";
model="Mayon";
price=350;
break;}
quantity=JOptionPane.showInputDialog(null, "\nProduct: "+product+
"\nBrand: "+Brand+
"\nModel: "+model+
"\nPrice: "+price+
"\n\nQuality:");
quantityInt=Integer.parseInt(quantity);
totalamount=price*quantityInt;
amountRecieve=JOptionPane.showInputDialog(null,"It em you Choose: \nProduct: "+product+
"\nBrand: "+Brand+
"\nModel: "+model+
"\nPrice: "+price+
"\n\nQuality:","\nTotal Amount: "+totalamount+"\n\nAmount Receive:");
double receive=Double.parseDouble(amountRecieve);
double change=receive-totalamount;
String PurchaseAgain=JOptionPane.showInputDialog(null,"\n You want to order again?"
+ "\n [Y]es [N]o",JOptionPane.QUESTION_MESSAGE);
if("Y".equals(PurchaseAgain)||"y".equals(PurchaseA gain)){
}
else if("N".equals(PurchaseAgain)||"n".equals(PurchaseA gain)){
JOptionPane.showMessageDialog(null, "Thank you for shopping");
}
else{
JOptionPane.showMessageDialog(null,"Invalid Choice:","Please try Again",JOptionPane.WARNING_MESSAGE+JOptionPane.OK_ OPTION);}
}
exit1=true;
//-----------end Looping
ch3=str.charAt(0);
Character.toLowerCase(ch3);
do{
switch(ch3){
case 'L':
case 'l':{
str=JOptionPane.showInputDialog(null," List of Laptop \n"
+ " Brand Model Price\n"
+ "[S]: Sony SuperShot $899\n"
+ "[H]: HP Hyperstone $967\n"
+ "[A]: Acer Arrow777 $867\n"
+ "\n[B]: Back to menu"
+"\n\nAdd to cart:");
ch3=str.charAt(0);
Character.toLowerCase(ch3);
switch(ch3){
case's':
case'S':{
JOptionPane.showMessageDialog(null,"\nThis will be added in your Information\n"
+ "Brand: Sony\nModel: SuperShot\nPrice: $899");
Brand="SONY";
model="SuperShot";
price=899;
}break;
case'H':
case'h':{
JOptionPane.showMessageDialog(null,"\nThis will be added in your Information\n"
+ "Brand: HP\nModel: Hyperstone\nPrice: $967");
Brand="HP";
model="Hyperstone";
price=967;
} break;
case'A':
case'a':{
JOptionPane.showMessageDialog(null,"\nThis will be added in your Information\n"
+ "Brand: Acer\nModel: Arrow77\nPrice: $867");
Brand="ACER";
model="Arrow777";
price=867;
} break;
quantity=JOptionPane.showInputDialog(null, "\nProduct: "+product+
"\nBrand: "+Brand+
"\nModel: "+model+
"\nPrice: "+price+
"\n\nQuality:");
quantityInt=Integer.parseInt(quantity);
totalamount=price*quantityInt;
amountRecieve=JOptionPane.showInputDialog(null,"It em you Choose: \nProduct: "+product+
"\nBrand: "+Brand+
"\nModel: "+model+
"\nPrice: "+price+
"\n\nQuality:","\nTotal Amount: "+totalamount+"\n\nAmount Receive:");
double receive=Double.parseDouble(amountRecieve);
double change=receive-totalamount;
String PurchaseAgain=JOptionPane.showInputDialog(null,"\n You want to order again?"
+ "\n [Y]es [N]o",JOptionPane.QUESTION_MESSAGE);
if("Y".equals(PurchaseAgain)||"y".equals(PurchaseA gain)){
}
else if("N".equals(PurchaseAgain)||"n".equals(PurchaseA gain)){
JOptionPane.showMessageDialog(null, "Thank you for shopping");
}
else{
JOptionPane.showMessageDialog(null,"Invalid Choice:","Please try Again",JOptionPane.WARNING_MESSAGE+JOptionPane.OK_ OPTION);}
}
exit1=false;
//--------------end Looping
ch4=str.charAt(0);
Character.toLowerCase(ch4);
do{
switch (ch4){
case 't':
case 'T' :{
str=JOptionPane.showInputDialog(null,"List of Cellphone \n"
+" Brand Medel Price\n"
+ "[A]: Apple iPadMini $129\n"
+ "[S]: Samsung GalaxyTab $292\n"
+ "[C]: Cherry Mobile Superion $120\n\n"
+ "[B]: Back to menu"
+"Add to Puschase Item:");
ch4=str.charAt(0);
Character.toLowerCase(ch4);
switch(ch4){
case 'A':
case'a':{
JOptionPane.showMessageDialog(null,"This will bi added in Puschase Item\n"
+ "\nBrand: Apple\nModel: iPadMini\nPrice: $129");
Brand="Apple";
price=329;
model="iPadMini";
break;}
case 'C':
case'c':{
JOptionPane.showMessageDialog(null,"This will bi added in Puschase Item\n"
+ "\nBrand: Samsung\nModel: GalaxyTab\nPrice: $292");
Brand="Samsung";
price=292;
model="GalaxyTab";
break;}
case'S':
case's':{
JOptionPane.showMessageDialog(null,"This will bi added in Puschase Item\n"
+ "\nBrand: Cherry Mobile\nModel: Superion\nPrice: $120");
Brand="Cherry Mobile";
price=120;
model="Superion";
break;}
quantityInt=Integer.parseInt(quantity);
totalamount=price*quantityInt;
amountRecieve=JOptionPane.showInputDialog(null,"It em you Choose: \nProduct: "+product+
"\nBrand: "+Brand+
"\nModel: "+model+
"\nPrice: "+price+
"\n\nQuality:","\nTotal Amount: "+totalamount+"\n\nAmount Receive:");
double receive=Double.parseDouble(amountRecieve);
double change=receive-totalamount;
String PurchaseAgain=JOptionPane.showInputDialog(null,"\n You want to order again?"
+ "\n [Y]es [N]o",JOptionPane.QUESTION_MESSAGE);
if("Y".equals(PurchaseAgain)||"y".equals(PurchaseA gain)){
}
else if("N".equals(PurchaseAgain)||"n".equals(PurchaseA gain)){
JOptionPane.showMessageDialog(null, "Thank you for shopping");
}
else{
JOptionPane.showMessageDialog(null,"Invalid Choice:","Please try Again",JOptionPane.WARNING_MESSAGE+JOptionPane.OK_ OPTION);}
}
//---------------end Looping
ch4=str.charAt(0);
Character.toLowerCase(ch4);
do{
switch(ch4){
case'I':
case'i':{
JOptionPane.showMessageDialog(null,"Name: "+name+
"\nAge: "+age+
"\nAddress: "+address+
"\nGender: "+gender+
"\nProduct: "+product+
"\nQuantity: "+quantity+
"\nBrand: "+Brand+
"\nModel: "+model+
"\nPrice: "+price
," Your Information",JOptionPane.WARNING_MESSAGE+JOptionPa ne.OK_OPTION);
inFile.append("Name: "+name+
"\nAge: "+age+
"\nAddress: "+address+
"\nGender: "+gender+
"\nProduct: "+product+
"\nQuantity: "+quantity+
"\nBrand: "+Brand+
"\nModel: "+model+
"\nPrice: "+price);
inFile.println();
inFile.close();
} break;
case'E':
case'e':{
JOptionPane.showMessageDialog(null,"Bye na ! ");
}break;
default:{
JOptionPane.showMessageDialog(null,"Invalid Choice:","Please try Again",JOptionPane.WARNING_MESSAGE+JOptionPane.OK_ OPTION);
}break;
}
} //----------- end of switch case
while(ch!='e');//-------------------------->end loop
inFile.close();
inFile.close();
}}
System.exit(0);
}
}
}
}