2.19 Warm up: Variables, input, and casting (Java) Instructor notes While you will be submitting this assignment through Zybooks, make sure you are still applying appropriate formatting and in-line...



2.19 Warm up: Variables, input, and casting (Java) Instructor notes While you will be submitting this assignment through Zybooks, make sure you are still applying appropriate formatting and in-line commenting. (1) 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.


Enter integer: 99


Enter double: 3.77


Enter character: z


Enter string: Howdy


99 3.77 z Howdy


(2) Extend to also output in reverse.


Enter integer: 99


Enter double 3.77


Enter character: z


Enter string: Howdy


99 3.77 z Howdy Howdy z 3.77 99 (


3) Extend to cast the double to an integer, and output that integer.


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


Here is the given java code:


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


System.out.println("Enter integer: ");


userInt = scnr.nextInt();


// FIXME (1): Finish reading other items into variables, then output the four values on a single line separated by a space


// FIXME (2): Output the four values in reverse // FIXME (3): Cast the double to an integer, and output that integer return;


} }


I can't seem to get the current answer in Expert Q & A to work.


Nov 11, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here