Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . 3 8 Variables, input, and casting ( Java ) ( 1 ) Prompt the user to input an integer, a double, a character,

1.38 Variables, input, and casting (Java)
(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. (Submit for 2 points).
Enter integer: 99
Enter double: 3.77
Enter character: z
Enter string: Howdy
993.77 z Howdy
(2) Extend to also output in reverse. (Submit for 1 point, so 3 points total).
Enter integer: 99
Enter double: 3.77
Enter character: z
Enter string: Howdy
993.77 z Howdy
Howdy z 3.7799
(3) Extend to cast the double to an integer, and output that integer. (Submit for 2 points, so 5 points total).
Enter integer: 99
Enter double: 3.77
Enter character: z
Enter string: Howdy
993.77 z Howdy
Howdy z 3.7799
3.77 cast to an integer is 3
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
// FIXME (2): Output the four values in reverse
Run your program as often as you'd like, before submitting for grading. Below, type any needed
input values in the first box, then click Run program and observe the program's output in the
second box.
Enter program input (optional)
If your code requires input values, provide them here.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

a. Describe the encounter. What made it intercultural?

Answered: 1 week ago