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]
3 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]3 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
If reading or writing a cache line of size 64 bytes to Flash requires 2.56 μJ and DRAM requires 0.5 nJ, and if idle power consum
kumpel [21]

Answer:

Total DRAM memory = 1.6 * 8 * 10^9 Bytes J/seconds = 12.8*10^9 J/s ---1

Total energy required to read or write cache-line to Flash and DRAM = 2*64*( 2.56 *10^-6+0.5 *10^-9) J = 3.277*10^-4 J---2

The time a system will be idle is 2/1 = 2.56*10^-14 seconds

Explanation:

Here, the 2 and 1 in the last step corresponds to the answers from equation equation 1 and equation 2.

8 0
3 years ago
Question 1
Margaret [11]

First of all, the print statements should be indented, and the last if statement should be x % 2 == 1 inside of the parentheses.

Other than those few mistakes, the output of the program when the user types in 9 is:

A

C

and whatever the last thing is in the final if statement.

I hope this helps!

8 0
3 years ago
WILL GIVE BRAINLIEST! 20 POINTS! PLZ HELP!
alukav5142 [94]

Answer:

B

Explanation:

== returns true if both the left side and right side are equal

8 0
3 years ago
Read 2 more answers
Whats a hybrid wired network
LuckyWell [14K]
A hybrid network is any computer network that uses more than one type of connecting technology or topology. For example, a home network that uses both Wi-Fi and Ethernet cables to connect computers is a hybrid.
5 0
3 years ago
Write a test program that creates two Rectangle objects—one with width 4 and height 40 and the other with width 3.5 and height 3
BARSIC [14]

Answer:

public class Rectangle {

   private double width;

   private double heigth;

   public Rectangle(double width, double heigth) {

       this.width = width;

       this.heigth = heigth;

   }

   public double getWidth() {

       return width;

   }

   public void setWidth(double width) {

       this.width = width;

   }

   public double getHeigth() {

       return heigth;

   }

   public void setHeigth(double heigth) {

       this.heigth = heigth;

   }

   public double perimeter(double width, double heigth){

       double peri = 2*(width+heigth);

       return peri;

   }

   public double area(double width, double heigth){

       double area = width*heigth;

       return  area;

   }

}

class RectangleTest{

   public static void main(String[] args) {

       //Creating two Rectangle objects

       Rectangle rectangle1 = new Rectangle(4,40);

       Rectangle rectangle2 = new Rectangle(3.5, 35.7);

       //Calling methods on the first Rectangel objects

       System.out.println("The Height of Rectangle 1 is: "+rectangle1.getHeigth());

       System.out.println("The Width of Rectangle 1 is: "+rectangle1.getWidth());

       System.out.println("The Perimeter of Rectangle 1 is: "+rectangle1.perimeter(4,40));

       System.out.println("The Area of Rectangle 1 is: "+rectangle1.area(4,40));

       // Second Rectangle object

       System.out.println("The Height of Rectangle 2 is: "+rectangle2.getHeigth());

       System.out.println("The Width of Rectangle 2 is: "+rectangle2.getWidth());

       System.out.println("The Perimeter of Rectangle 2 is: "+rectangle2.perimeter(4,40));

       System.out.println("The Area of Rectangle 2 is: "+rectangle2.area(4,40));

   }

}

Explanation:

  • Firstly A Rectangle class is created with two fields for width and heigth, a constructor and getters and setters the class also has methods for finding area and perimeters
  • Then a RectangleTest class containing a main method is created and two Rectangle objects are created (Follow teh comments in the code)
  • Methods to get height, width, area and perimeter are called on each rectangle object to print the appropriate value
5 0
3 years ago
Other questions:
  • Pros and cons of Processor Throttling or Scaling?
    13·1 answer
  • to prevent long page load time for pages containing images. It is best to use a compress file formatlike jpeg as well as appropr
    6·2 answers
  • Susan bought a new sweater on sale for $28.93.she was charged HST of 13%.find the total amount of her bill including taxes.​
    9·1 answer
  • In the structure of a conventional processor, what is the purpose of the data path?
    15·1 answer
  • Briefly explain five measures you have undertaken to protect your confidential
    12·1 answer
  • Which is an example of an incremental approach to solving a problem?
    15·1 answer
  • An administrator has created a new custom object in a sandbox environment and now is ready to deploy in production. How can the
    11·1 answer
  • Karl comes across confidential information. What should he do with it? A. Manipulate the information in his favor B. Sell the in
    12·1 answer
  • What is a file type and why is it important? Give at least three examples of file
    7·1 answer
  • Hypertext enables you to navigate through pieces of information by clicking the __________, that connect them.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!