Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.text.NumberFormat;
- import java.util.Locale;
- public class Menu {
- public static void main(String[] args) {
- NumberFormat formatter = NumberFormat.getCurrencyInstance();
- NumberFormat formatter2 = NumberFormat.getCurrencyInstance(Locale.GERMAN);
- String name = "Menu";
- double dollar, dMark;
- DecimalFormat format = new DecimalFormat("0.00");
- String dBalls = "Koenigsberger Klopse";
- String dPotatoes = "Dampfkartoffeln";
- String dBeans = "Gruene Bohnen";
- String dSalad = "Gurkensalat";
- String dPudding = "Quarkspeise";
- String balls = "Meatballs in White Sauce";
- String potatoes = "Boiled Potatoes";
- String beans = "Green Beans";
- String salad = "Cucumber Salad";
- String pudding = "Quark Pudding";
- double moneyAmount1 = 3.35;
- double moneyAmount2 = 1.11;
- double moneyAmount3 = 1.11;
- double moneyAmount4 = 2.23;
- double moneyAmount5 = 1.67;
- // Use 20 spaces for the title Menu, printed right justified
- System.out.printf("\n%20s\n", name);
- // The title of each dish should be printed within 25 spaces, right justified
- // Insert a tab between the title and the pricing of each dish
- // Each pricing should be printed within 7 spaces, right justified
- System.out.printf("%25s %7s %25s %7s\n" +
- "%25s %7s %25s %7s\n" +
- "%25s %7s %25s %7s\n" +
- "%25s %7s %25s %7s\n" +
- "%25s %7s %25s %7s\n", dBalls, formatter2.format(moneyAmount1), balls,
- formatter.format(moneyAmount1),
- dPotatoes, formatter2.format(moneyAmount2), potatoes, formatter.format(moneyAmount2),
- dBeans, formatter2.format(moneyAmount3), beans, formatter.format(moneyAmount3),
- dSalad, formatter2.format(moneyAmount4), salad, formatter.format(moneyAmount4),
- dPudding, formatter2.format(moneyAmount5), pudding, formatter.format(moneyAmount5));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment