dimanche 2 mai 2021

how to make my GUI appear more then once and take that input

Hi im new to programming and i need to make a program that answers this question and im stuck currently stuck on this.

Prompt the user to choose an item from the menu using number 1, 2 or 3 that corresponds to the membership or extra options (s)he prefers, else the user enters 0 to quit. If the user chooses 1, show the input box again and if the user then chooses 0, show the cost of the membership chosen. If the user chooses extras from the menu before entering a 0, add the price of the extra and show it to the user. If the user chooses all three, add the three and show the cost to the user.

i dont understand how to make the gui appear more then once and still take an input.

package onlineapplication;

import javax.swing.JOptionPane; public class Onlineapplication {

public static void main(String[] args) {
 String result;
  int one=350;
  int two=450;
  int three=550;
 int input;
   String calculations;       
   
  
   result =   JOptionPane.showInputDialog(null,"(1)Basic membership     "+one+" \n(2)Specials          "+two+"\n (3)VIP treatment      "+three+"  \nmake selection.Press 0 to quit",JOptionPane.INFORMATION_MESSAGE);     

  
   input= Integer. parseInt(result);
   
   
 
   
   if(input==1 && input ==0)JOptionPane.showMessageDialog(null, "Your total cost comes to "+one); 
   if(input==2 && input ==0)JOptionPane.showMessageDialog(null, "Your total cost comes to "+two);
   if(input==3 && input ==0)JOptionPane.showMessageDialog(null, "Your total cost comes to "+three);
   
   if(input==1 && input==2 && input==0)   JOptionPane.showMessageDialog(null, "Your total cost comes to 800"+one+two); 
   if(input==1 && input==3 && input==0)   JOptionPane.showMessageDialog(null, "Your total cost comes to 800"+one+three); 
   if(input==2 && input==3 && input==0)   JOptionPane.showMessageDialog(null, "Your total cost comes to 800"+three+two); 
   
   if(input==1 && input==2 && input==3 )JOptionPane.showMessageDialog(null, "Your total cost comes to 1350");

 
    }

  }

Aucun commentaire:

Enregistrer un commentaire