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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:30, giannav57
How do you set up a slide show to play continuously, advancing through all the slides without requiring your interaction? a. click set up slide show, and then select the loop continuously until ‘esc' and show without narration options. b. click set up slide show, and then select the loop continuously until ‘esc' and use timings, if present options. c. click set up slide show, and then select the show presenter view and use timings, if present options. d. click set up slide show, and then select the show without animation and browsed at a kiosk (full screen) options.
Answers: 3
image
Computers and Technology, 23.06.2019 10:00, lamanihill
Now, open this passage to read about fafsa requirements. describe the information you will need to provide in order to complete a fafsa. list at least three of the required documents you must include.
Answers: 3
image
Computers and Technology, 23.06.2019 13:10, BrianKeokot4534
What is domain name system (dns)? allows dynamic ip address allocation so users do not have to have a preconfigured ip address to use the network converts ip addresses into domains, or identifying labels that use a variety of recognizable naming conventions the efficient coexistence of telephone, video, and data communication within a single network, offering convenience and flexibility not possible with separate infrastructures the integration of communication channels into a single service
Answers: 2
image
Computers and Technology, 23.06.2019 18:00, bubbles173883
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a. edit the sizes and other characteristics of photos that have been inserted. b. take a screenshot of an image and copy it to the clipboard for pasting. c. search for drawings or other images from a library of prepared pictures. d. make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
You know the right answer?
In Java please.
Write a code that prompts the user to input an integer, a double, a character,...

Questions in other subjects: