Skip to content
Snippets Groups Projects
Commit 2e328679 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Switched to command-line-argument input.

parent e18291ca
No related branches found
No related tags found
No related merge requests found
......@@ -4,12 +4,12 @@ import java.util.Scanner;
public class Sum {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number: ");
double firstNumber = scanner.nextDouble();
System.out.print("Enter another number: ");
double secondNumber = scanner.nextDouble();
scanner.close();
Scanner firstScanner = new Scanner(args[0]);
double firstNumber = firstScanner.nextDouble();
firstScanner.close();
Scanner secondScanner = new Scanner(args[1]);
double secondNumber = secondScanner.nextDouble();
secondScanner.close();
double sum = firstNumber + secondNumber;
System.out.println("The sum is " + sum + ".");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment