Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(IN JAVA): 1.) How are you able to put quotation marks around two words outputted from a java program? (I want my code to represent

(IN JAVA):

1.) How are you able to put quotation marks around two words outputted from a java program? (I want my code to represent the desired sample output image down below)

-------- I have coded this so far --------------

import java.util.Scanner;

public class Main {

public static void main(String[] args) { Scanner sc = new Scanner(System.in);

System.out.println("Next enter two words:"); String word1 = sc.nextLine(); String word2 = sc.nextLine(); System.out.println("You entered " + word1 + " and " + word2);

--------------------------------------

So this works! I just am not sure how to make it so there are double quotes surrounding the strings word1 and word2.

2.) How are you able to output multiple words (like shown in the image below)? I have tried using the variable string just like I did in the code above, but it will only output the first word of the sentence! Please help

image text in transcribed

Next enter two words: plastic spoons You entered "plastic" and "spoons" Next enter a line of text: May the hair on your toes grow long and curly. You entered "May the hair on your toes grow long and curly

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions