Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class CookieJOpt {
  4. public static void main (String[] args)
  5. {
  6.  
  7. String input, galleta;
  8. double sugar = 1.5/48;// amount needed per cookie
  9. double butter = 1/48;
  10. double flour = 2.75/48;
  11.  
  12. galleta =
  13. JOptionPane.showInputDialog(null,"How many cookies would you like to bake?");
  14. int cookie = Integer.parseInt(galleta);
  15. JOptionPane.showMessageDialog(null,String.format("You will need:\n" + "Sugar %s,.3f" +
  16. sugar*cookie + "\nButter %s,.3f" + butter*cookie + "\nFlour %s,.3f" + flour*cookie));
  17. System.exit(0);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement