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
PLEASEEE HELPPP im gonna cry
Sindrei [870]

Your answer is:

B. toolbar

5 0
3 years ago
Read 2 more answers
Intellectual property piracy has gotten a small boost from the increasing availability of counterfeit goods through Internet cha
Aliun [14]

Answer:

The answer is "Option B".

Explanation:

Intellectual property is protected by law in which property, copyright, and trademarks, are uses, that enable you to gain individuals' popularity or personally benefit according to what they create.

  • It is a program that helps to create an environment, in which imagination and technology are used.
  • It will change the growth by striking a balance between innovator rights and wider public interest.
3 0
3 years ago
Which printout will result from the snippet of code?
Anna35 [415]

Answer:

These are the supplies in the list:  

[‘pencil’, ‘notebook’, ‘backpack’, ‘pen’, ‘calculator’]

Explanation:

The line return (\n) character will be in the output (so there will be a change of line), but it will NOT be visible as it would have been interpreted as a special character.

So the output will be on 2 different lines, with no \n visible.

If the command would have been: print('These are the supplies in the list:\n', supplies), with single quotes (') instead of double quotes (") then then \n would have been printed but not interpreted as a special character.  At least in most computer language.  Since we don't know of which language the question refers to, we can't be sure at 100%.

7 0
3 years ago
Write a recursive method that takes four inputs: a 1-D array of Strings (i.e., exams), the length of this 1-D array (i.e., n), a
ale4655 [162]

Answer:

import java.util.*;

public class Main

{

       public static void main(String[] args)  

       {

           String [] exams = {"1;2;3;4;" , "5;6;7;8;" , "9;10;11;12;" };

           double[][] n = new double[exams.length][4];

           examArray = convert(exams , exams.length , 0 , n);

           for(int i = 0 ; i < exams.length ; i++)

           {

               for(int j = 0 ; j < 4 ; j++)

               {

                   System.out.print(n[i][j] + "\t");

               }

              System.out.print("\n");

           }

       }    

       

/* recursive function convert defined here */

       public static double[][] convert(String[] exams , int number , int x , double [][] result)

       {

           if(x==number)

               return result;

           else

           {

               String total = exams[x];  

               String currentScore = "";

               int p = 0;

               for(int j = 0 ; j<totalScore.length() ; j++)

               {

                   char ch = total.charAt(j);/

                   if(ch==';')

                   {

                       result[x][p] = Double.parseDouble(currentScore);

                       p++;

                       currentScore = "";

                   }

                   else

                   {

                       currentScore = currentScore + Character.toString(ch);

                   }

               }

               return convert(exams , number , x+1 , result);

           }

           

       }

}

Explanation:

The Java source code defines a recursive function or method called convert that converts the results of three students that sat for four examinations to double or float number and screens their individual results for the four exams on the screen.

5 0
3 years ago
How do you do the animation code?
egoroff_w [7]
Just for extra practice I recommend using khan academy lesson what's for dinner
5 0
3 years ago
Other questions:
  • Where is the bubble level on a tripod?
    6·2 answers
  • PLEASE HELP
    13·2 answers
  • Give two reasons why cloud computing could be harmful to an organization.<br> (No choices!)
    15·1 answer
  • Hey so, I was looking online how to reset my laptop and I ended up pressing load setup defaults and now I get an error saying ch
    15·2 answers
  • Write a file path for a document file that is saved on the F drive then a folder called homework, then a folder called math. The
    12·1 answer
  • According to the video, what are some hazards Stationary Engineers may face? Check all that apply. noise, hazardous materials, d
    7·2 answers
  • How many months have 28 days?
    8·1 answer
  • A small business named Widgets, Inc. has hired you to evaluate their wireless network security practices. As you analyze their f
    13·1 answer
  • The process of providing only the essentials and hiding the details is known as _____. Group of answer choices algorithm abstrac
    6·1 answer
  • 13. You're emailing your grandparents. Which of the following is the best example of digital etiquette?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!