diff options
author | Sudipto Mallick <smlckz@bccr> | 2024-01-10 13:53:54 +0530 |
---|---|---|
committer | Sudipto Mallick <smlckz@bccr> | 2024-01-10 13:53:54 +0530 |
commit | 5ea0ab6272277357c847ce324582e08cff58d134 (patch) | |
tree | 870571d13f1fb6f0135463e1d1d71e05dbd0c641 /java/text | |
parent | a914804458e9697f1a9e0430c72ffe941582bbf5 (diff) | |
download | zadania-5ea0ab6272277357c847ce324582e08cff58d134.tar.gz |
Incorporate changes to Java assignment #5
Updating assignment as directed
Diffstat (limited to 'java/text')
-rw-r--r-- | java/text/AddTwoNumbers.typ | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/java/text/AddTwoNumbers.typ b/java/text/AddTwoNumbers.typ index 0ef86fa..b0d6128 100644 --- a/java/text/AddTwoNumbers.typ +++ b/java/text/AddTwoNumbers.typ @@ -1,7 +1,6 @@ #import "/template.typ": * #show: A => apply(A) #set raw(lang: "java-new") -#set par(leading: 0.575em) #assignment(5)[ Write a program to add two numbers by taking input from command line arguments, the `Scanner` class and the `BufferedReader` class. @@ -17,12 +16,12 @@ - `static double parseDouble(String)`: Try to parse the provided string as a `double` value. - `java.util.Scanner` class: - `double nextDouble()`: Scan a `double` value from the the input stream. -- `java.io.IOException` class represents the exception to be thrown when an error occurs while performing an I/O operation. - `java.io.BufferedReader` class provides for he efficient reading of characters, arrays, and lines from a character-input stream, buffering characters. - Constructor `BufferedReader(Reader)`: Creates a buffering character-input stream for the provided reader stream. - `String readLine()`: Returns a line of text from the input stream. - `java.io.InputStreamReader` class adapts a byte stream into character stream using a specific character set encoding. - Constructor `InputStreamReader(InputStream)`: Creates a reader stream for characters from the provided input stream with the default character set encoding. +- `java.io.IOException` class represents the exception to be thrown when an error occurs while performing an I/O operation. - `java.util.InputMismatchException` is thrown by the methods of `Scanner` class when encountering invalid input. - `java.lang.NumberFormatExeption` is thrown by `parseDouble` method when the provided string does not constitute a valid `double` value. @@ -33,12 +32,10 @@ - `double valueOf()`: Returns the underlying number. - The `ArithmeticOperations` class has methods implementing operations on `Number`s. - `static Number add(Number, Number)`: Adds two `Number`s provided and returns the sum as a `Number`. -- `AddTwoNumbers` class contains the operation of adding when the two numbers have been provided. +- `AddTwoNumbers` class contains the operation of adding when the two numbers have been provided and orchestrates the main program with the `main()` method: - `static void process(double, double)`: Performs addition by creating `Number` objects from the two provided `double` values. -- The `AddTwoNumbersCLI` orchestrates a main program with: - - `public static void main(String[])`: Implements addition of two numbers by taking input from command line arguments. -- The `AddTwoNumbersScan` orchestrates a main program with: - - `public static void main(String[])`: Implements addition of two numbers by taking input utilising `java.util.Scanner`. -- The `AddTwoNumbersBuf` orchestrates a main program with: - - `public static void main(String[])`: Implements addition of two numbers by taking input using `java.io.BufferedReader`. + - `public static void main(String[])`: Implements addition of two numbers by taking input: + - From command line arguments, + - Utilising `java.util.Scanner`, and + - Using `java.io.BufferedReader`. #signature() |