Question

In: Computer Science

Design a phone purchase program in JOptionPane. Select model ( can be made up 2 models...

Design a phone purchase program in JOptionPane.

Select model ( can be made up 2 models minimum)

Color selection( 2 options minimum)

Storage Selection( 2 options minimum)

Accessories (2 options minimum)

Payment Plan or one time purchase

Prices can be made up

Print out price. Allow user termination. Create a class and test programs.

Solutions

Expert Solution

Code:

import java.util.ArrayList;
import javax.swing.JOptionPane;
class market {
 public static void main(String[] args) {

    int MenuList;  
    String myOrder = "No order currently set";     //if no any item purchsed then print this message 
        do{  
                System.out.println("---MENU---");
                //here there are 3 options availabel 1 is for purchase 2 is for print purchased order 3 is for exit  
                String[] menu = {"[1]Purchase Phone","[2]print","[3]exit"};  
                        
                for (int i=0;i<3;i++) {    //display 3 options in command prompt
                        System.out.println(menu[i]);
                }

                String MenuString = JOptionPane.showInputDialog(null, " Choose number: ");   //get selected option
                MenuList = Integer.parseInt(MenuString);

                int price = 0;
                if(MenuList==1) {       //if option is 1 then go for purchase program
                        System.out.println();
                        String[] model = {"iPhone11","iPhone12"};
                        String[] color = {"Red","Black","Green"};
                        String[] storage = {"64GB","128GB"};
                        String[] acc = {"Airpods","Covor"};
                        String[] payment = {"Cash","Card"};

                        myOrder = "";
                        
                        //here you can choose one by one options first you have to select model then color then storage then accessories then payment option
                        String Model = (String) JOptionPane.showInputDialog(null,"Select Model", "Welcome " +  "!",JOptionPane.QUESTION_MESSAGE, null, model, "iPhone11");
                        String Color = (String) JOptionPane.showInputDialog(null,"Select Color","",JOptionPane.QUESTION_MESSAGE, null, color, "Black");
                        String Storage = (String) JOptionPane.showInputDialog(null,"Select Storage","",JOptionPane.QUESTION_MESSAGE, null, storage, "64GB");
                        String Acc = (String) JOptionPane.showInputDialog(null,"Select Accessories ","",JOptionPane.QUESTION_MESSAGE, null, acc, "Covor");
                        String pay = (String) JOptionPane.showInputDialog(null,"Select payment method","",JOptionPane.QUESTION_MESSAGE, null, payment, "Cash");
                        
                        //here it calculate total price of item
                        if(Model=="iPhone11")
                                price+=50000;
                        else
                                price+=60000;   
                        if(Storage=="64GB")
                                price+=5000;
                        else
                                price+=8000;
                        if(Acc=="Airpods")
                                price+=5000;
                        else
                                price+=500;
                        
                        //for display a selected options and total price of item
                        myOrder="Your model is: "+Model+"\nYour Color is: "+Color+"\nYour Storage is: "+Storage+"\nYour Accessories is: "+Acc+"\nYour Payment method is: "+pay;
                        myOrder+="\n\nYour total price is: "+price;
                } else if(MenuList==2) {      //if option is 2 then and any item is purchased then print purchased item otherwise print default message
                        JOptionPane.showMessageDialog(null,myOrder);
                } else if(MenuList==3) {
                        JOptionPane.showMessageDialog(null,"Exit,Bye");   //if option is 3 selected then exit
                } else {
                        System.out.print("Invalid");
                }
        }while(MenuList != 3);   //it go untill you select option 3
 }
}

Output:

It display 3 option. then if you want go for purchase program then enter 1.

Then enter 2 for print select item and price.

Then enter 3 for exit.


Related Solutions

Design an AC RLC circuit that can supply power to a load which is made up...
Design an AC RLC circuit that can supply power to a load which is made up of an 8 - mu*F capacitor and a resistor with a resistance that can be varied between 600 Q and 800 The average power consumed by the circuit must be 2 kW or less and the power factor must be above 0.95 for all conditions of the load. The frequency of the power supply is 50 Hz. The design should include an inductor and...
Design an AC RLC circuit that can supply power to a load which is made up...
Design an AC RLC circuit that can supply power to a load which is made up of an 8 - mu*F capacitor and a resistor with a resistance that can be varied between 600 Q and 800 The average power consumed by the circuit must be 2 kW or less and the power factor must be above 0.95 for all conditions of the load. The frequency of the power supply is 50 Hz. The design should include an inductor and...
1. Select 3 materials that you think are best for the design of a smart phone...
1. Select 3 materials that you think are best for the design of a smart phone back plate cover (not protection case) : One Metal, One Polymer and One Carbon Fibre composite. 2. Specify the details of the EXACT material grade selected for each of the three material variations of the smart phone case(specify the resin type). 3. What would be the best choice of material for the phone case from the three options?
a simplified model of the eye is made up of pupil, a crystal lens and a...
a simplified model of the eye is made up of pupil, a crystal lens and a retina. but what is the optical component corresponding to the crystal lens?
2. What decisions can be made by a supply chain network design application? • Inventory level...
2. What decisions can be made by a supply chain network design application? • Inventory level and procurement • The number of facilities to build • Production quantity at each facility • Distribution and service links in the network What data is needed for a typical supply chain network design? Transportation cost rate Demand of customers or service locations Fixed cost of building a facility Geographical information of locations There ca be several answers
1) Is myelin continuously being made? 2) can you come up with a good analogy for...
1) Is myelin continuously being made? 2) can you come up with a good analogy for the time course of the action potential?
List the Marketing Objectives for a newly design Samsung model Android based mobile phone using the...
List the Marketing Objectives for a newly design Samsung model Android based mobile phone using the SMART criteria. Create a mission and vision statement
Provide an introduction on the topic of consumer behavior. Select a purchase that you recently made...
Provide an introduction on the topic of consumer behavior. Select a purchase that you recently made and reflect on the purchase decision process. Explain in detail how each step in this process affected your purchase decision. Describe how each of the 4Ps (product, price, promotion, and distribution) affected your purchase decision. Technology is a tool that companies use to influence consumers. Discuss the impact of the internet at every step of the purchasing decision process. The letter concludes by explaining...
6. Store your important phone numbers in a hash. Write a program to look up umbers...
6. Store your important phone numbers in a hash. Write a program to look up umbers by the person’s name in perl language.
Suppose the Bank of Canada made an announcement that it would purchase up to $500 billion...
Suppose the Bank of Canada made an announcement that it would purchase up to $500 billion of long term Canada bonds over the following six month. What effect might this policy has on the yield curve? Explain in detail. During the current economic crisis caused by the Coronavirus, what would you expect the yiedd curve to look like? Upward sloping, flat, or inverted.Explain in detail.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT