Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am working on this lab and no matter what I do I can't get this coding to work correctly. Please help!! Here's the assignment.
I am working on this lab and no matter what I do I can't get this coding to work correctly. Please help!!
Here's the assignment.
Variables, input, and casting Java
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. Submit for points
Enter integer:
Enter double:
Enter character: z
Enter string: Howdy
z Howdy
Extend to also output in reverse. Submit for point, so points total
Enter integer:
Enter double:
Enter character: z
Enter string: Howdy
z Howdy
Howdy z
Extend to cast the double to an integer, and output that integer. Submit for points, so points total
Enter integer:
Enter double:
Enter character: z
Enter string: Howdy
z Howdy
Howdy z
cast to an integer is
Here's my coding:
import java.util.Scanner;
public class BasicInput
public static void mainString args
Scanner scnr new ScannerSystemin;
int userInt ;
double userDouble ;
char userChar;
String userString;
System.out.printEnter integer: ;
userInt scnrnextInt;
System.out.printEnter double: ;
userDouble scnrnextDouble;
System.out.printEnter character: ;
userChar scnrnextcharAt;
System.out.printEnter string: ;
userString scnrnext;
System.out.printlnuserInt userDouble userChar userString;
System.out.printlnuserString userChar userDouble userInt;
System.out.printlnuserDouble cast to an integer is intuserDouble;
return;
Here's the output Im getting which is incorrect:
Program output displayed here
Enter integer: Enter double: Enter character: Enter string: z Howdy
Howdy z
cast to an integer is
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started