Using the javautilScanner library as shown in class create a

Using the java.util.Scanner library, as shown in class, create a Java program that gets inputs from the keyboard: a first name (e.g. Dev), a last name (e.g. Smith), and any two integer numbers (e.g. 13 and 32), then outputs a print out of all of those variables, along with the sum of the two integers, in the following fashion (all on one line):

Hello, Dev Smith! The sum of 13 and 32 is 45. Goodbye!

Solution

import java.util.Scanner;   class ScannerTest{   public static void main(String args[]){      Scanner sc=new Scanner(System.in);            System.out.println(\"Enter your first name\");   String firstName=sc.next();      System.out.println(\"Enter your name\");      String socndName=sc.next();      System.out.println(\"Enter first number\");      double firstNumber = sc.nextDouble(); System.out.println(\"Enter second number\");      double secondNumber = sc.nextDouble(); double total = secondNumber +firstNumber ;    System.out.println(\"Hello,\"+firstName+\" \"+ socndName+\"! The sum of\"+ firstNumber +\"and\"+ secondNumber +\"is \"+total +\". Goodbye!\");      sc.close();   }   }   
Using the java.util.Scanner library, as shown in class, create a Java program that gets inputs from the keyboard: a first name (e.g. Dev), a last name (e.g. Smi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site