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
DIA [1.3K]
4 years ago
7

(1) prompt the user for a string that contains two strings separated by a comma. (1 pt) examples of strings that can be accepted

: jill, allen jill , allen jill,allen ex: enter input string: jill, allen
Computers and Technology
1 answer:
GalinKa [24]4 years ago
5 0

package parsestrings;

import java.util.Scanner;

public class ParseStrings {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in); // Input stream for standard input

Scanner inSS = null; // Input string stream

String lineString = ""; // Holds line of text

String firstWord = ""; // First name

String secondWord = ""; // Last name

boolean inputDone = false; // Flag to indicate next iteration

// Prompt user for input

System.out.println("Enter input string: ");

// Grab data as long as "Exit" is not entered

while (!inputDone) {

// Entire line into lineString

lineString = scnr.nextLine()

// Create new input string stream

inSS = new Scanner(lineString);

// Now process the line

firstWord = inSS.next();

// Output parsed values

if (firstWord.equals("q")) {

System.out.println("Exiting.");

inputDone = true;

if (firstWord.matches("[a-zA-Z]+,[a-zA-Z]+")) {

System.out.print("Input not two comma separated words");

}

} else {

secondWord = inSS.next();

System.out.println("First word: " + firstWord);

System.out.println("Second word: " + secondWord);

System.out.println();

}

}

return;

}

}

You might be interested in
A7DF is the hexadecimal representation for what bit pattern?
kipiarov [429]

Answer:

1010 0111 1101 1111

Explanation:

A = 10 in decimal = 1010 in binary

7 = 7 in decimal = 0111 in binary

D = 13 in decimal = 1101 in binary

F = 15 in decimal = 1111 in binary

Therefore 0xA7DF = 1010 0111 1101 1111 in binary

6 0
3 years ago
2.3 Code Practice: Question 3
Tpy6a [65]

Answer:

Code in C++

Explanation:

C++ Code

#include<iostream> //for input and output  

using namespace std;  

int main()  

{  

  int hour;

  int minute;

  cout<<"Enter the hour:";

  cin>> hour;

  cout<<"Enter the minute:";

  cin>>minute;

  minute = minute+15;

  if(minute>=60){

   hour++;

   minute=minute-60;

  }

  if(hour>=24){

   hour=0;

  }

  cout<<"Hours: "<<hour<<endl;

  cout<<"Minutes:"<<minute;

  return 0;  

}

Code Explanation

First we need to declare two int variables to hold hour and minute values input from user.

Check if by adding 15 minutes into minute entered by user is greater then or equal to 60 then increment into hour and subtract 60 from minute.

Another check is that if user enters more then 24 hour or by making increment into hour, the hour values i greater then or equal to 24 then we need to change the hour to 0.

Result

Case 1:

Enter the hour:8

Enter the minute:15

Hours: 8

Minutes:30

Case 2:

Enter the hour:9

Enter the minute:46

Hours: 10

Minutes:1

8 0
3 years ago
1. What are the two things the base of a number system tells you? After describing these two things, illustrate each with exampl
Alexxx [7]
Using our normal decimal numbering system, the base of a number system, for example 8, tells us two things

1. Each digit is an integer that uses numbers from 0 to 7. There are 8 possible values for a digit
2. We multiply each digit by a power of 8 depending on the position of the digit.

If we use number 112 to (base 8), then; 

<span>(1 x 8 to the power of 2) + (1 x 10 to the power of 1) + (2 x 8 to the power of 0).   </span>


3 0
4 years ago
Which best describes the benefits of renting a home?
WARRIOR [948]
The benefits are that you don't have to worry if something breaks from like a water leake or a storm and get destroyed the home owners have to pay
7 0
4 years ago
Read 2 more answers
What are 25 items that trees made?
alexandr1967 [171]

Answer:

(things,can't think of more

.......)

  • paper
  • charcoal
  • doors
  • chairs
  • jewelry
  • wood frames
  • broom handles
  • furniture made with wood
6 0
3 years ago
Read 2 more answers
Other questions:
  • Can embedded computers automate security so you can lock and unlock doors remotely
    15·1 answer
  • You've created a letter from a blank document. To format this letter with a unified font, colors, and effects you'll apply a A.g
    6·2 answers
  • The picture that graphically represents the items you use in Windows is called a/an
    15·1 answer
  • By using the internet, your company can obtain discounts thorugh...
    15·2 answers
  • Why information technology is important in healthcare?
    13·1 answer
  • Identify the symbol. please help!!<br>​
    7·2 answers
  • Consider the graph of the function f(x) = 2(x + 3)2 + 2. Over which interval is the graph decreasing? (–∞, –3) (–∞, 2) (–3, ∞) (
    10·2 answers
  • Imagine that a time machine has transported you back to an earlier civilization or historical era. Poking through your backpack,
    12·1 answer
  • What are the methods used in research methodology?
    12·1 answer
  • Which device allows users to directly hear data from a computer
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!