Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Guys what's wrong in my Simple Program ? Help me please :(

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Guys what's wrong in my Simple Program ? Help me please :(

    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);

    }
    }










    }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Guys what's wrong in my Simple Program ? Help me please :(

    Welcome to the forum! Please read this topic to learn how to post code correctly and other useful info for new members.

    Please edit your post so that your code is posted correctly with formatting preserved. Then, describe what you need help with, ask specific questions and/or include error messages so that we know why you've posted.

Similar Threads

  1. Replies: 8
    Last Post: December 30th, 2013, 12:34 AM
  2. Please help to understand whats the wrong with my guess. - Simple program
    By rayan2004 in forum Object Oriented Programming
    Replies: 1
    Last Post: December 14th, 2012, 01:03 AM
  3. Simple sorting program, can't figure out whats wrong with my code
    By USC CSCE in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 29th, 2012, 08:38 AM
  4. What's wrong with simple Scanner program?
    By SV25 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 21st, 2011, 07:05 AM
  5. help guys.. could you tell me what am i doing wrong?
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 12th, 2011, 02:59 PM