Create a program that when run with a name, an integer and a double as CMD arguments, it prints out a greeting using the name and also print the difference of the two given numbers
import java.util.Scanner;
public class Main {
private static void report(String name, int number1, double number2) {
// Create a program that when run with a name,
// an integer and a double as CMD arguments,
// it prints out a greeting using the name and
// also print the difference of the two given numbers
double difference = number1 - number2;
System.out.println("Welcome, " + name);
System.out.println(number1 + " - " + number2 + " = " + difference);
}
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter name: ");
String name = keyboard.nextLine();
System.out.print("Enter a number 1: ");
int number1 = keyboard.nextInt();
System.out.print("Enter a number 2: ");
int number2 = keyboard.nextInt();
report(name, number1, number2);
keyboard.close();
}
}
Comments
Leave a comment