diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/Listing0712.java | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing0712.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/Listing0712.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing0712.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing0712.java new file mode 100644 index 0000000..d42bf24 --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing0712.java @@ -0,0 +1,29 @@ +/* Listing0712.java */
+
+public class Listing0712
+{
+ public static void registrierKasse(Object... args)
+ {
+ double zwischensumme = 0;
+ double gesamtsumme = 0;
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] instanceof Number) {
+ zwischensumme += ((Number)args[i]).doubleValue();
+ } else {
+ System.out.println(args[i] + ": " + zwischensumme);
+ gesamtsumme += zwischensumme;
+ zwischensumme = 0;
+ }
+ }
+ System.out.println("Gesamtsumme: " + gesamtsumme);
+ }
+
+ public static void main(String[] args)
+ {
+ registrierKasse(
+ 1.45, 0.79, 19.90, "Ware",
+ -3.00, 1.50, "Pfand",
+ -10, "Gutschein"
+ );
+ }
+}
\ No newline at end of file |
