Answer to Question #244775 in Java | JSP | JSF for Tumutangeni

Question #244775

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               


1
Expert's answer
2021-09-30T04:46:01-0400
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();
	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS