1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KonstantinChe [14]
3 years ago
11

(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. (2 pts) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter integer: 99 Enter double: 3.77 Enter character: 2 Enter string: Howdy 99 3.77 z Howdy (2) Extend to also output in reverse (1 pt) Enter integer: 99 Enter double 3.77 Enter characteri Enter string: Howdy 99 3.772 Howdy Howdy z 3.77 99 (3) Extend to cast the double to an integer, and output that integer (2 pts) 0 en soa Enter integer: 99 Enter double: 3.77 Enter character: 2 Enter string: Howdy 99 3.77 z Howdy Howdy z 3.77 99 3.77 cast to an integer is 3 LAB ACTIVITY 14.1.1: Prog 1: Variables, input, and casting 0/5 BasicInput.java Load default template. 1 ort java.util.Scanner: 2 3 lic class Basic Input I 4 public static void main(String args) { 5 Scanner ser-new Scanner(System.in); 6 int userint; 7 double userDouble; B // FTOME Define chor and string variables similarly 9 char UserChar: 10 String userString: 11 12 System.out.println("Enter integer"): 13 user Int - ser.nextInto: 14 15 // FTXMC (1): Finish reading other items inte variables, then output the four values on a single line separated by a space
Computers and Technology
1 answer:
Alex787 [66]3 years ago
6 0

Answer:

import java.util.*;

public class Main{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

 int intgVal; double dblVal; char chrVal; String strVal;

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

 intgVal = input.nextInt();

 System.out.print("Enter double: ");  

 dblVal = input.nextDouble();

 System.out.print("Enter character: ");  

 chrVal = input.next().charAt(0);

 input.nextLine();

 System.out.print("Enter string: ");  

 strVal = input.nextLine();

 System.out.println(intgVal+" "+dblVal+" "+chrVal+" "+strVal);

 System.out.println(strVal+" "+chrVal+" "+dblVal+" "+intgVal);

 int IntValue = (int) dblVal;

 System.out.print("Cast to an integer: "+IntValue);

}

}

Explanation:

See attachment for complete program where comments were used to explain each line of the program

Download txt
You might be interested in
Your brother is a video producer and is looking to buy some sort of new computing device. he needs a lot of memory and processin
mafiozo [28]
He should purchase a Desktop PC as it would allow him to install high-power parts such as RAM, Graphics Card and CPU.
3 0
2 years ago
What are the basic data types supported in C programing language?
Murljashka [212]

Answer:

The C language provides the four basic arithmetic type specifiers char, int, float and double, and the modifiers signed, unsigned, short, and long.

6 0
2 years ago
Is it possible for a PowerPoint user to add notes to slides and see the added comments
Arturiano [62]

Answer:

I am not for sure on this, but yes I think it is possible for the PowerPoint user to add notes to slides and see the added comments. If it isn't possible I know for a fact on Google slides it is possible.

:

hope this helps! :)

7 0
3 years ago
What can be defined as in information technology environment?
natka813 [3]
Here is your answer

7 0
3 years ago
Read 2 more answers
What are two preferences a user can indicate for the Junk Email folder?
marysya [2.9K]
Did you mean this?
<span>Controls are divided between two locations: (a) </span>Tools -> Options<span> -> Security -> Junk, and (b) Tools -> Account Settings -> *each account* -> Junk Settings.</span>
5 0
3 years ago
Read 2 more answers
Other questions:
  • * Declare a variablecalled "car" of type "Car", and initialise its value to a new instance of the "Car"class.
    9·1 answer
  • Describe mobile computing
    7·1 answer
  • Assume that the following code exists inside a method of MyClass, and that this code compiles without errors: int result = book.
    13·1 answer
  • Jana keeps receiving friend requests from strangers on a social media site. This is making her uncomfortable.
    15·2 answers
  • The item that is clicked in a JList can be retrieved using the _____ method of JList.
    8·1 answer
  • Ergonomically designed workstations and equipment reduce stress-related injuries and improve the productivity and efficiency of
    13·2 answers
  • Pseudocode is a good choice to communicate a____of a process
    10·1 answer
  • Political parties to address the interest of civil society<br>​
    7·1 answer
  • Which influence on spending deals with the motivation to<br> purchase a product?
    12·1 answer
  • What do you mean by Graphics editing​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!