Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(IN JAVA): How are you able to print multiple numbers/ words on a single line of code?? I want to code a program that will

(IN JAVA): How are you able to print multiple numbers/ words on a single line of code??

I want to code a program that will look exactly like the "sample screen output" image I've provided below, so how I started was I coded this so far:

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

import java.util.Scanner;

public class Main {

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

System.out.println("Enter two whole numbers separated by one or more spaces:"); int num = scan.nextInt(); System.out.println(num); } }

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

I'm now realizing the scanner is not picking up on the second number I entered, only the 1st one! I am not sure why! Someone help me, please

image text in transcribed

Sample Screen Output Enter two whole numbers separated by one or more spaces: 42 43 You entered 42 and 43 Next enter two numbers. A decimal point is OK. 9.99 21 You entered 9.99 and 21.0 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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

What are a managers options if more control isnt possible?

Answered: 1 week ago