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
AlekseyPX
3 years ago
8

Which method call converts the value in variable stringVariable to an integer?

Computers and Technology
1 answer:
zlopas [31]3 years ago
3 0

Answer:

The correct answer for the given question is Integer.parseInt( string variable );

Explanation:

Integer.parseInt( string variable ); is the method in a java programming language that convert the string into the integer value. It takes a string variable and converted into the integer.

Following are the program in java which convert the string value into an integer value.

class Main  

{

 public static void main(String []args) // main function

{

   String str1 = "10009";

// variable declaration

   int k = Integer.parseInt(str1);

// convert the string into integer.

   System.out.println("Converted into Int:" + k);

}

}

Output:

Converted into Int:10009

Convert.toInt( stringVariable );

Convert.parseInt( stringVariable,Integer.toInt( stringVariable ); are not any method to convert the string into integer .

Therefore the correct answer is :Integer.parseInt( stringVariable );

You might be interested in
Write a program. in QBAsSIC
goblinko [34]

Answer:

The program is as follows:

<em>5 INPUT A,B</em>

<em>6 PROD = A * B</em>

<em>7 PRINT PROD</em>

<em>8 TOTAL = A + B</em>

<em>9 PRINT TOTAL</em>

<em>10 DIFF = A - B</em>

<em>11 PRINT DIFF</em>

<em>12 END</em>

Explanation:

This gets input for the two numbers

<em>5 INPUT A,B</em>

This calculates the product

<em>6 PROD = A * B</em>

This prints the calculated product

<em>7 PRINT PROD</em>

This calculates the sum

<em>8 TOTAL = A + B</em>

This prints the calculated sum

<em>9 PRINT TOTAL</em>

This calculates the difference

<em>10 DIFF = A - B</em>

This prints the calculated difference

<em>11 PRINT DIFF</em>

This ends the program

<em>12 END</em>

5 0
2 years ago
Complete the getNumOfCharacters() method, which returns the number of characters in the user's string. We encourage you to use a
photoshop1234 [79]

Answer:

The Java code is given below with appropriate comments

Explanation:

//Program

//Import the necessary libraries

import java.util.Scanner;

//Define the class

public class CountStringCharacters

{

//Start the main method

public static void main(String[] args)

{

//Prompt the user to enter the input line

Scanner scan = new Scanner(System.in);

System.out.println("Enter a sentence or phrase: ");

String s = scan.nextLine();

 

//Take the number of characters and keep the count

int numOfCharacters = getNumOfCharacters(s);

System.out.println("You entered: "+s);

System.out.println("Number of characters: "+numOfCharacters);

 

//Call the method outputWithoutWhitespace

outputWithoutWhitespace(s);

}

//The method getNumOfCharacters

public static int getNumOfCharacters(String s)

{

int numOfCharCount = 0;

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

{

numOfCharCount++;

}

return numOfCharCount;

}

//Definition of the method outputWithoutspace

public static void outputWithoutWhitespace(String s)

{

String str = "";

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

{

char ch = s.charAt(i);

if(ch != ' ' && ch != '\t')

str = str + ch;

}

System.out.println("String with no whitespace: "+str);

}

}

5 0
3 years ago
Write a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in
morpeh [17]

Answer:

See explaination

Explanation:

PhoneLookup.java

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

public class PhoneLookup

{

public static void main(String[] args) throws IOException

{

Scanner in = new Scanner(System.in);

System.out.println("Enter the name of the phonebook file: ");

String fileName = in.nextLine();

LookupTable table = new LookupTable();

FileReader reader = new FileReader(fileName);

table.read(new Scanner(reader));

boolean more = true;

while (more)

{

System.out.println("Lookup N)ame, P)hone number, Q)uit?");

String cmd = in.nextLine();

if (cmd.equalsIgnoreCase("Q"))

more = false;

else if (cmd.equalsIgnoreCase("N"))

{

System.out.println("Enter name:");

String n = in.nextLine();

System.out.println("Phone number: " + table.lookup(n));

}

else if (cmd.equalsIgnoreCase("P"))

{

System.out.println("Enter phone number:");

String n = in.nextLine();

System.out.println("Name: " + table.reverseLookup(n));

}

}

}

}

LookupTable.java

import java.util.ArrayList;

import java.util.Collections;

import java.util.Scanner;

/**

A table for lookups and reverse lookups

*/

public class LookupTable

{

private ArrayList<Item> people;

/**

Constructs a LookupTable object.

*/

public LookupTable()

{

people = new ArrayList<Item>();

}

/**

Reads key/value pairs.

atparam in the scanner for reading the input

*/

public void read(Scanner in)

{

while(in.hasNext()){

String name = in.nextLine();

String number = in.nextLine();

people.add(new Item(name, number));

}

}

/**

Looks up an item in the table.

atparam k the key to find

atreturn the value with the given key, or null if no

such item was found.

*/

public String lookup(String k)

{

String output = null;

for(Item item: people){

if(k.equals(item.getName())){

output = item.getNumber();

}

}

return output;

}

/**

Looks up an item in the table.

atparam v the value to find

atreturn the key with the given value, or null if no

such item was found.

*/

public String reverseLookup(String v)

{

String output = null;

for(Item item: people){

if(v.equals(item.getNumber())){

output = item.getName();

}

}

return output;

}

}

Item.java

public class Item {

private String name, number;

public Item(String aName, String aNumber){

name = aName;

number = aNumber;

}

public String getName(){

return name;

}

public String getNumber(){

return number;

}

}

input.txt

Abbott, Amy

408-924-1669

Abeyta, Ric

408-924-2185

Abrams, Arthur

408-924-6120

Abriam-Yago, Kathy

408-924-3159

Accardo, Dan

408-924-2236

Acevedo, Elvira

408-924-5200

Acevedo, Gloria

408-924-6556

Achtenhagen, Stephen

408-924-3522

Note: Replace all the "at" with at symbol

4 0
3 years ago
A business letter should always include the address of the sender.<br> True<br> False
8090 [49]

Answer:

true

Explanation:it is true because like that they could send that letter were it go's so like that they don't have trouble looking for the person's letter

please mark me as brainlist

3 0
3 years ago
Read 2 more answers
________ results when leisure time and available tools allow us to engage in creative acts.
natta225 [31]
Cognitive surplus results when leisure time and available tools allow us to engage in creative acts. It is a term that was introduced by Clay Shirky which pertains to the synthesis of the excess of people's energy, time and creativity leading to productivity sharing and creation.
4 0
2 years ago
Other questions:
  • Write a MATLAB script using the quiver and contour commands to visualize the field and its divergence. Assume the region of inte
    12·1 answer
  • I am confused about joins in sql.
    8·2 answers
  • On a wireless router, what gives out IP addresses?<br> DHCP<br> DNS<br> WPA<br> WPS
    7·1 answer
  • Which type of malware can hijack internal windows components and often goes undetected because it is already loaded when the ant
    14·1 answer
  • Heather has segmented all of the individuals in her database into four categories according to how many game tickets they purcha
    12·2 answers
  • Suppose that f() is a function with a prototype like this: void f(________ head_ptr); // Precondition: head_ptr is a head pointe
    15·1 answer
  • Which of the following lists the proper order of the categories of the SOC system from general to specific?
    11·1 answer
  • Question 21 pts How many lines should an email signature be? Group of answer choices "5 to 6" "7 to 8" "1 to 2" "3 to 4"
    10·1 answer
  • What is the difference between php and html?​
    13·2 answers
  • By the mid-1990s, how did revenue generated from video games compare to revenue generated from movies?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!