subject

In Java please.
Write a code that prompts 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. The output to be look like:
Enter integer:
99
Enter double:
3.77
Enter character:
z
Enter string
Howdy
99 3.77 z Howdy
Howdy z 3.77 99
3.77 cast to an integer is 3
1. Below is the code that is giving error, please provide the correct code for above requirement.
import java. util. Scanner;
public class BasicInput {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
int userInt = 0;
double userDouble = 0.0;
// FIXME Define char and string variables similarly
String randomcharacter = " ";
String enterstring = " ";
Character randomc = ' ';
System. out. println("Enter integer: ");
userInt = scnr. nextInt();
System. out. println("Enter double: ");
userDouble = scnr. nextDouble();
System. out. println("Enter character: ");
randomcharacter = scnr. nextLine();
randomc = randomcharacter. charAt(0);
System. out. println("Enter string: ");
enterstring = scnr. next();
System. out. println(userInt + " " + userDouble + " " + randomc + " " + enterstring);
System. out. println(enterstring + " " + randomc + " " + userDouble + " " + userInt);

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:00
The following function returns a string of length n whose characters are all 'x'. give the order of growth (as a function of n) of the running time. recall that concatenating two strings in java takes time proportional to the sum of their lengths. public static string f(int n) { if (n == 0) return ""; if (n == 1) return "x"; return f(n/2) + f(n - n/2); } options: a) constant b) logarithmic c) linear d) linearithmic e)quadratic f)cubic g) exponential
Answers: 2
question
Computers and Technology, 23.06.2019 20:40
On nba 2k 19, every time i try to join a my park game, it leads ro a website telling my dad that he needs ps plus. i already have ps plus though. how do i fix this?
Answers: 2
question
Computers and Technology, 24.06.2019 05:30
How do i get rid of my member ship for
Answers: 2
question
Computers and Technology, 25.06.2019 05:00
Brad wants to buy flowers for his friend with 33 dollars.the daisies are 1 dollar each and the roses are 2 dollars each he buy 3 more daisies than roses how much did the roses cost
Answers: 2
You know the right answer?
In Java please.
Write a code that prompts the user to input an integer, a double, a character,...
Questions
question
World Languages, 22.08.2019 12:30
Questions on the website: 13722361