Using Java Write Program Takes Outputs String Integer Floating Point Number Separated Comm Q37136200

Using Java, write a program that takes outputs a string, aninteger and a floating-point number separated by commas.

Sample output: Bob Marley, 20, 5.2


Solution


//Main.javaimport java.util.Scanner;public class Main { public static void main(String args[]){ Scanner scanner = new Scanner(System.in); System.out.print(“Enter string: “); String s = scanner.nextLine(); System.out.print(“Enter int value: “); int i = scanner.nextInt(); System.out.print(“Enter float value: “); float f = scanner.nextFloat(); System.out.println(s+”, “+i+”, “+f); }}

Enter string: Bob Marley Enter int value: 20 Enter float value: 5.2 Bob Marley, 20, 5.2 Process finished with exit code 0

below if Note: Please comment below if you have any doubts you have any d

Enter

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.