title: Ordering system
body: <p>I am stuck on the last part of this project. I have gotten all the other parts to work at least at the level that I need them to. I have it set up to where a customer can make selections about their product such as: type, color, material, and the number of the item they wish to order. Now I have to assign a price to the items. I do not want the type or color to affect the price only the material so it should be fairly simple. Once they select a price either paper or cardboard they will get the output message with their total cost (including tax). I have over looked something as I cannot even find a starting point as which to assign the costs to the item material selected. Below is the code that I have written, I am unsure how to add the portion I need. Any help would be great.</p>
  
  <pre><code>package pcos;
  
  import java.io.*;
  import java.util.*;
  import java.lang.*;
  import javax.swing.*;
  
  public class pcos {
      public static void main(String[] args)throws Exception {
          String openingMsg, nameInputMsg, customerName, nameOutputMsg,
              returnInputMsg, customerReturn, orderTypeMsg, customerType, returnOutputMsg, finalTotalAmt,
              orderColorMsg, customerColor, orderCoatMsg, customerCoat, itemAmountMsg, customerItemAmount, itemAmtOutptMsg, frameOutputMsg, greetingOutputMsg, outputMsg;
          //display opening message 
          openingMsg = "*** Welcome to the Diamond Playing Cards Online Ordering System ***\n"; 
          JOptionPane.showMessageDialog(null, openingMsg);
          //get required input using dialog boxes
          nameInputMsg = "Enter your name: "; 
          customerName = getstringInput( nameInputMsg );
          returnInputMsg = "Have you ordered from us before (yes or no)? "; 
          customerReturn = getstringInput( returnInputMsg );
          orderTypeMsg = "What type of deck to you need Standard, Uno, Rook?";
          customerType = getstringInput(orderTypeMsg);
          orderColorMsg = "What color do you want your deck to be Red, Green, Blue, or Black?";
          customerColor = getstringInput(orderColorMsg);
          orderCoatMsg = "Do you prefer a clear laminate or a plastic coating on your cards?" + ".\n" + "Card coating     (Type)           Cost" + ".\n" + "                      Laminated         $2.00" + ".\n" +       "                     Plastic Coating     $2.50" ;
          customerCoat = getstringInput(orderCoatMsg);
          itemAmountMsg = "Please enter the number of your selected item you wish to purchase?" ;
          customerItemAmount =getstringInput(itemAmountMsg);
  
          //build output strings 
          nameOutputMsg = "Welcome " + customerName + ".\n";
          returnOutputMsg = "Your return customer status is " + customerReturn + ".\n";
          itemAmtOutptMsg= "You have slected to purchase " + customerItemAmount + ' ' + customerColor + ' ' + customerType + "(s)" +  " with " + customerCoat + " coating(s).\n"; ;
          finalTotalAmt= "The total cost of your purchase after taxes will be" + "\n";
          greetingOutputMsg = "     Thank you for visiting Diamond Playing Cards Online!" + "\n";
          //create output string 
          outputMsg = nameOutputMsg + returnOutputMsg + itemAmtOutptMsg + finalTotalAmt +greetingOutputMsg;
          //display output message
          JOptionPane.showMessageDialog( null, outputMsg );
          System.exit(0);
      }
  
      private static String getstringInput(String prompt){
          int count = 0;
          String input;
          input = JOptionPane.showInputDialog( prompt );
          while ((input != null &amp;&amp; input.length() == 0) &amp;&amp; (count &lt;2)){
              input = JOptionPane.showInputDialog("No input was detected. \n" + prompt);
              count++;
          }
          if (count==2){
              JOptionPane.showMessageDialog(null, " You did not make an entry please try again later when you are ready to order.  ORDER TERMINATING.");
              System.exit(0);
          }
          return input;
      }
  }
  </code></pre>
  
  <p>With the updates to the code it looks like this (though I decided to use double instead of float to keep things more accurate.   I am still having the issue of using the prices I have assigned.   I know I have to create some type of  expression but I cant figure out how to take the integer I get from the customers input * salesTax * cost of which ever type they select.  I Then I have to get it to display back to the user as in the outputMSG but that should be easy enough if I can just figure out the expression.</p>
  
  <pre><code>package pcos;
  
  import java.io.*;
  import java.util.*;
  import java.lang.*;
  
  import javax.swing.*;
  
  public class pcos {
      public static void main(String[] args)throws Exception {
          String openingMsg, nameInputMsg, customerName, nameOutputMsg,
              returnInputMsg, customerReturn, orderTypeMsg, customerType, returnOutputMsg, finalTotalAmt,
              orderColorMsg, customerColor, orderCoatMsg, customerCoat, itemAmountMsg, customerItemAmount, itemAmtOutptMsg, frameOutputMsg, greetingOutputMsg, outputMsg;
          //display opening message 
          openingMsg = "*** Welcome to the Diamond Playing Cards Online Ordering System ***\n"; 
          JOptionPane.showMessageDialog(null, openingMsg);
          //get required input using dialog boxes
          nameInputMsg = "Enter your name: "; 
          customerName = getstringInput( nameInputMsg );
          returnInputMsg = "Have you ordered from us before (yes or no)? "; 
          customerReturn = getstringInput( returnInputMsg );
          orderTypeMsg = "What type of deck to you need Standard, Uno, Rook?";
          customerType = getstringInput(orderTypeMsg);
          orderColorMsg = "What color do you want your deck to be Red, Green, Blue, or Black?";
          customerColor = getstringInput(orderColorMsg);
          orderCoatMsg = "Do you prefer a clear laminate or a plastic coating on your cards?" + ".\n" + "Card coating     (Type)           Cost" + ".\n" + "                      Laminated         $2.00" + ".\n" +       "                     Plastic Coating     $2.50" ;
          customerCoat = getstringInput(orderCoatMsg);
          itemAmountMsg = "Please enter the number of your selected item you wish to purchase?" ;
          customerItemAmount =getstringInput(itemAmountMsg);
          Integer.parseInt(customerItemAmount);
  
          //build output strings 
          nameOutputMsg = "Welcome " + customerName + ".\n";
          returnOutputMsg = "Your return customer status is " + customerReturn + ".\n";
          itemAmtOutptMsg= "You have slected to purchase " + customerItemAmount + ' ' + customerColor + ' ' + customerType + "(s)" +  " with " + customerCoat + " coating(s).\n"; ;
          finalTotalAmt= "The total cost of your purchase after taxes will be" + "\n";
          greetingOutputMsg = "     Thank you for visiting Diamond Playing Cards Online!" + "\n";
          //create output string 
          outputMsg = nameOutputMsg + returnOutputMsg + itemAmtOutptMsg + finalTotalAmt +greetingOutputMsg;
          //display output message
          JOptionPane.showMessageDialog( null, outputMsg );
          System.exit(0);
      }
  
      public static double typeLaminatePrice = 2.00;
      public static double typePlasticPrice = 2.50;
      public static double salesTaxRate = 0.10;
      double price;         
      if (customerFrame.equalsIgnoreCase("Plastic")) {
          price = typePlasticPrice;
      }else if (customerFrame.equalsIgnoreCase("Laminate")) {
          price = typeLaminatePrice;}  
      private static String getstringInput(String prompt){
          int count = 0;
          String input;
          input = JOptionPane.showInputDialog( prompt );
          while ((input != null &amp;&amp; input.length() == 0) &amp;&amp; (count &lt;2)){
              input = JOptionPane.showInputDialog("No input was detected. \n" + prompt);
              count++;
          }
          if (count==2){
              JOptionPane.showMessageDialog(null, " You did not make an entry please try again later when you are ready to order.  ORDER TERMINATING.");
              System.exit(0);
          }
          return input;
      }
  }
  </code></pre>