Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need assistance on this problem. Prompt the user to input an integer, a double,

ID: 3908515 • Letter: N

Question

Need assistance on this problem. Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space.

I have provided the Answer Template of which our output is suppose to look like. I also provided my coding which has resulted in some errors. Would appreciate the correct coding.

(3) Extend to cast the double to an integer, and output that integer. (2 pts) Enter integer: Enter double: 3.77 Enter character: Enter string Howdy 99 3.77 z Howdy Howdy z 3.77 99 ?. // ca3t t an integer î3 LAB ACTIVITY 2.14.1: Ch 2 Program, part 1: Variables, input, and casting (Java) Basiclnput.java 1 import java.util.scanner 3 public class BasicInput 4 public static void main(Stringil args) Scanner scnr -new Scanner (System.in); int userInt; double userDouble; char userCharacter; String userStrng; /I FIXME Define char and string variables similarly 10 12 13 14 15 16 System.out.println("Enter integer:"); userIntscnr.nextint(; System.out.println(userInt); System.out.println("Enter Double:"; userDouble -scnr.nextDouble) 18 System.out.println(userDouble);

Explanation / Answer

import java.util.Scanner; public class BasicInput { public static void main(String[] args) { Scanner in = new Scanner(System.in); int userInt; double userDouble; char userCharacter; String userString; System.out.println("Enter integer:"); userInt = in.nextInt(); System.out.println("Enter double:"); userDouble = in.nextDouble(); System.out.println("Enter character:"); userCharacter = in.next().charAt(0); System.out.println("Enter string:"); userString = in.next(); System.out.printf("%d %f %c %s ", userInt, userDouble, userCharacter, userString); System.out.printf("%s %c %f %d ", userString, userCharacter, userDouble, userInt); System.out.printf("%f cast to an integer is %d ", userDouble, (int)userDouble); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote