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
agasfer [191]
3 years ago
6

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).

Computers and Technology
1 answer:
Nutka1998 [239]3 years ago
6 0

Answer:

// name of the package

package stringlength;

// Scanner is imported but it is not needed

// So it is commented

// import java.util.Scanner;

// The class name StringLength is defined

public class StringLength {

// main method to signify the beginning of program execution

public static void main(String[] args) {

// if-statement to check if argument is supplied to

// command line

if(args.length > -1) {

// the first argument is read and assigned to input

String input = args[0];

int length = input.length(); // using length() method in String class

System.out.println("Your string has a length of "+length+" characters.");

} else {

System.out.println("Please enter your string argument in quote");

}

}

}

Explanation:

The code works fine with little modification and comments. The user should supply the string arguments in quote. The quote must surround the strings because our logic read the first argument passed to the command line. Inserting a string with space between them will provide a wrong output.

A sample image is attached.

You might be interested in
Write a program that reads the number of stalls and then prints out diagrams in the format given above when the stalls become fi
Solnce55 [7]

Answer:

/* package whatever; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

public class Ideone

{

  public static final int STALL_COUNT = 10;

 

public static int find_stall(boolean[] stalls) {

int longest_count = -1;

int longest_length = 0;

int current_count = -1;

int current_length = 0;

boolean inRun = false;

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

if (inRun && stalls[i]) {

inRun = false;

if (current_length >= longest_length) {

longest_length = current_length;

longest_count = current_count;

}

 

}

else if (!inRun && !stalls[i]) {

inRun = true;

current_count = i;

current_length = 1;

}

else if (inRun && !stalls[i]) {

current_length += 1;

}

}

if (inRun) {

if (current_length >= longest_length) {

longest_length = current_length;

longest_count = current_count;

}

}

return (longest_length - 1) / 2 + longest_count;

}

 

public static void print_pattern(boolean[] stalls) {

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

if (stalls[i]) {

System.out.print("X ");

}

else {

System.out.print("_ ");

}

}

System.out.println();

}

 

  public static void main (String[] args) throws java.lang.Exception

  {

      boolean[] stalls = new boolean[STALL_COUNT];

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

stalls[find_stall(stalls)] = true;

print_pattern(stalls);

  }

}

}

3 0
4 years ago
Does anyone have 2.19.4 Guess a number 2.0 code for codehs?
lubasha [3.4K]

Answer:

I'm trying to create a program that will ask the user for an exam score in the range 0 to 100. ... I want to take the python course but I have not class code, anyone can help?

Explanation:

3 0
3 years ago
Which of these is a biotic factor in a forest?
Masteriza [31]
Climate because it is
7 0
3 years ago
What measures are needed to trace the source of various types of packets used in a DoS attack? Are some types of packets easier
cestrela7 [59]

<u>Explanation:</u>

Note, a DoS (Denial of Service) attack is <u>different in scope from a DDoS (Distributed Denial of Service) </u>attack. In a DoS attack, the attack on the website's network comes from just a single source (IP address) repeatedly, while in a DDos attack several Ip addresses or sources attack the network of a website.

To trace the source of various types of packets used in a DoS attack (which of less complexity than a DDos attack), a software application like Wireshark could be used to measure trace the packets used in the attack.

4 0
3 years ago
What does Digital Citizenship mean to you?
Nikolay [14]
A digital citizen refers to a person who has the knowledge and skills to effectively use digital technologies to communicate with others, participate in society and create and consume digital content. Digital citizenship is about confident and positive engagement with digital technologies. Digital citizenship refers to responsible technology usage, and teaching digital citizenship is essential to helping students achieve and understand digital literacy, as well as ensuring cyberbullying prevention, online safety, digital responsibility, and digital health and wellness.
5 0
3 years ago
Other questions:
  • How can a user choose settings that will customize a presentation so that it is best to be played automatically at a kiosk rathe
    11·2 answers
  • .Pretend you are ready to buy a new computer for personal use.First, take a look at ads from various magazines and newspapers an
    7·1 answer
  • List five ways in which the type declaration system of a language such as Java or C differs from the data definition language us
    8·1 answer
  • What is a mortgage?
    8·2 answers
  • In fixed-width files, each record is on a separate line and the fields are separated by a special character.
    7·1 answer
  • How do you pass graphic design. I have to make a project with a picture in the letter.
    6·1 answer
  • Assume the availability of a function named oneMore. This function receives an integer and returns one more than its parameter.
    14·1 answer
  • An actual printout of computer data always satisfies the best evidence rule?
    12·1 answer
  • A program that doesn’t work properly needs to be debugged. true or false
    8·1 answer
  • You have purchased a new LED monitor for your computer. On the back of the monitor, you see the following port (pictured below).
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!