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
lutik1710 [3]
2 years ago
6

Write a method named showChar. The method should accept two arguments: a reference to a String object and an integer. The intege

r argument is a character position within the String, with the first character being at position 0. When the method executes, it should display the character at that character position. The method does not return anything. Here is an example of a call to the method: showChar("New York", 2); In this call, the method will display the character w because it is in position 2. Demonstrate the method in a complete program. Sample Run java Method_showChar Enter a line of text: The elevation of Mount Everest is 29,029 feet (8,848·in·meters)↵ Enter yourindex:3 5↵ 9↵
Computers and Technology
1 answer:
matrenka [14]2 years ago
5 0

A complete program with the method ShowCar:

import java.util.Scanner; // header file

public class ShowChar

{

public static void main(String[] args)

{

String lnOfText;

int i;

Scanner input = new Scanner(System.in);

System.out.print("Enter a line of text:");

lnOfText = input.nextLine();

System.out.print(" Enter your index: ");

i = input.nextInt();

show_Char(lnOfText,i);

}

public static void show_Char(String str_a, int i)

{

System.out.print(str_a.charAt(i));

}

}

In this program, both the inputs ie. a sentence or line of text as well as the index position is obtained. A method is written to find the string at that particular position. Finally the method prints that character at the particular index.

You might be interested in
Project using simple formulas
Mrac [35]
Please explain more
7 0
3 years ago
Use the STL class vector to write a C function that returns true if there are two elements of the vector for which their product
Tema [17]

Answer:

Code is provided in the attachment form

Explanation:

Vector Multiplication code:

Vector_multiplication.c file contains C code.

See attachment no 1 attached below

Classification of Algorithm: For creating elements in vector c of size n, number of scalar  multiplications is equal to n. The size of original two vectors scales directly with the number of  operations. Hence, it is classified as O(n).

7 0
3 years ago
What are the layers in the internet protocol stack? what are the principle responsibilities of each of these layers?
Andrew [12]
1: Application
2: Presentation
3:Session
4: Transport
5:Network 
6: Data link 
7: Physical

Application is a Interface Layer and responsible Layer
<span />
3 0
2 years ago
What is the oldest malware victor
arsen [322]

Answer:

The oldest malware vector was emails.

Explanation:

Websites were not widespread early on into the internet, however it was very easy to have a virus that uses an email contact list, where it can send itself to other email addresses and spread.

7 0
3 years ago
What legal punishment can people face for plagerism
Maru [420]
They can get a fine.
5 0
3 years ago
Other questions:
  • List and describe the tools for all the main stages of app/application development.
    11·1 answer
  • Write a program to calculate the great circle distance between two points on the surface of a sphere. If p1(x1, y1) and p2(x2,y2
    5·1 answer
  • When a block of steel at 90 degrees Celsius is placed in a bucket of water at 30 degrees Celsius, what happens?
    10·1 answer
  • What is a directed graph?
    5·1 answer
  • I prefer a job where I am praise for good performance or I am accountable for results
    13·1 answer
  • I want to start a debate about something
    9·2 answers
  • Your customer said that understanding the directions is difficult. This is an aspect of
    6·1 answer
  • The output of a computer can be seen on ( monitor, keyboard or mouse )​
    5·2 answers
  • What would be an ideal scenario for using edge computing solutions?
    6·1 answer
  • Answer the following question in 3-4 complete sentences. Define the following terms: - registration - press - keyblock.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!