binibiningtinamoran

Menu

Oct 11th, 2019
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.12 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.text.NumberFormat;
  3. import java.util.Locale;
  4.  
  5. public class Menu {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         NumberFormat formatter = NumberFormat.getCurrencyInstance();
  10.         NumberFormat formatter2 = NumberFormat.getCurrencyInstance(Locale.GERMAN);
  11.         String name = "Menu";
  12.         double dollar, dMark;
  13.  
  14.         DecimalFormat format = new DecimalFormat("0.00");
  15.  
  16.         String dBalls = "Koenigsberger Klopse";
  17.  
  18.         String dPotatoes = "Dampfkartoffeln";
  19.  
  20.         String dBeans = "Gruene Bohnen";
  21.  
  22.         String dSalad = "Gurkensalat";
  23.  
  24.         String dPudding = "Quarkspeise";
  25.  
  26.         String balls = "Meatballs in White Sauce";
  27.  
  28.         String potatoes = "Boiled Potatoes";
  29.  
  30.         String beans = "Green Beans";
  31.  
  32.         String salad = "Cucumber Salad";
  33.  
  34.         String pudding = "Quark Pudding";
  35.  
  36.         double moneyAmount1 = 3.35;
  37.  
  38.         double moneyAmount2 = 1.11;
  39.  
  40.         double moneyAmount3 = 1.11;
  41.  
  42.         double moneyAmount4 = 2.23;
  43.  
  44.         double moneyAmount5 = 1.67;
  45.  
  46.         // Use 20 spaces for the title Menu, printed right justified
  47.         System.out.printf("\n%20s\n", name);
  48.  
  49.         // The title of each dish should be printed within 25 spaces, right justified
  50.         // Insert a tab between the title and the pricing of each dish
  51.         // Each pricing should be printed within 7 spaces, right justified
  52.         System.out.printf("%25s %7s %25s %7s\n" +
  53.                 "%25s %7s %25s %7s\n" +
  54.                 "%25s %7s %25s %7s\n" +
  55.                 "%25s %7s %25s %7s\n" +
  56.                 "%25s %7s %25s %7s\n", dBalls, formatter2.format(moneyAmount1), balls,
  57.                 formatter.format(moneyAmount1),
  58.                 dPotatoes, formatter2.format(moneyAmount2), potatoes, formatter.format(moneyAmount2),
  59.                 dBeans, formatter2.format(moneyAmount3), beans, formatter.format(moneyAmount3),
  60.                 dSalad, formatter2.format(moneyAmount4), salad, formatter.format(moneyAmount4),
  61.                 dPudding, formatter2.format(moneyAmount5), pudding, formatter.format(moneyAmount5));
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment