Computers and Technology, 24.05.2020 01:04 laryans317
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);
Answers: 2
Computers and Technology, 23.06.2019 09:00
The first screen you see when you open word2016 what is called?
Answers: 1
Computers and Technology, 23.06.2019 14:30
Choose the answers that best complete each sentence. on average,are more expensive than other kinds of postsecondary schools. the cost of room and board includes. to save money, some students attend auniversity in their home state.
Answers: 2
Computers and Technology, 23.06.2019 16:00
Which analyst position analyzes information using mathematical models to business managers make decisions?
Answers: 1
Computers and Technology, 23.06.2019 19:30
Of the following pieces of information in a document, for which would you most likely insert a mail merge field?
Answers: 3
In Java please.
Write a code that prompts the user to input an integer, a double, a character,...
Write a code that prompts the user to input an integer, a double, a character,...
Mathematics, 26.02.2021 15:50
Mathematics, 26.02.2021 15:50
Mathematics, 26.02.2021 15:50
Mathematics, 26.02.2021 15:50
Mathematics, 26.02.2021 15:50
Physics, 26.02.2021 15:50
Mathematics, 26.02.2021 15:50
Mathematics, 26.02.2021 15:50
Mathematics, 26.02.2021 15:50