Question

Write one statement to convert a numeric string s into a number and store the number into double variable i. Question 31 (2 p
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

1.

For converting numeric string into double number the statement is

double i=Double.parseDouble("-101.90");

double i=Double.parseDouble("102.9");

2.

For second question

String address="yuan"

String expression=address+"@google.com";

3.

For third question the output is Test12 Here "Test"+1+2 is nothing but concatenating or joining the strings

For better understanding see the below code snippet:

import java.util.Scanner;
public class Pattern
{
   public static void main(String args[])
       {
           Scanner input=new Scanner(System.in);
          
           //first question solution
           double negative_num=Double.parseDouble("-101.90"); //converting number to double
           double positive_num=Double.parseDouble("102.9");
           System.out.printf("Converting string '-101.90' into number %.2f\n" ,negative_num);
           System.out.printf("Converting string '102.9' into number %.2f\n" ,positive_num);

           //solution for second question
           System.out.print("Enter address: ");
           String address=input.nextLine(); //taking address from user
           String final_output=address+"@google.com"; //concatenating with string
           System.out.printf("%s\n",final_output);

           //solution for third question
           System.out.println("Test"+1+2); //evaluating the expression
       }
}
Code and Output Screenshots:

import java.util.Scanner; public class Pattern public static void main(String args[]) Scanner input=new Scanner (System.in);

Converting string -101.90 into number -101.90 Converting string 102.9 into number 102.90 Enter address: yuan yuan@google.

Note: if you have any queries please post a comment thanks a lot.always available to help you...

Add a comment
Know the answer?
Add Answer to:
Write one statement to convert a numeric string s into a number and store the number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Given a String variable address, write a String expression consisting of the string "http://" concatenated with...

    Given a String variable address, write a String expression consisting of the string "http://" concatenated with the variable's String value. So, if the variable refers to "www.turingscraft.com", the value of the expression would be "http://www.turingscraft.com". In python please

  • plz answers these short Qs in python language Q1-Given the String variable address, write an expression...

    plz answers these short Qs in python language Q1-Given the String variable address, write an expression that returns the position of the first occurrence of the String "Avenue" in address. Q2-Write a sequence of statements that finds the first comma in the string associated with the variable line, and associates the variable clause the portion of line up to, but not including the comma. Q3-Assume that sentence is a variable that has been associated with a string consisting of words...

  • In this question you have to write a C++ program to convert a date from one...

    In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of a main() function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the string that the function...

  • I have to write this in Python and it must run in Python 3. The last...

    I have to write this in Python and it must run in Python 3. The last two pictures are what I have so far please correct me if anything I have written so far is wrong. anything interesting 6.8. Do addition Summary Now you will replace the pass statement inside the addition case of the iflelif ladder with something that actually does addition. Since the only number we have right now is the accumulator, you will need to ask the...

  • u also need to store the letters' ASCII number in the freq array 4. [8] Write...

    u also need to store the letters' ASCII number in the freq array 4. [8] Write a C function with prototype ยท void letter_freq(const char word[], int freq []); This function computes the number of appearances of each letter in the string word and stores them in array freq of size 26. The letters are the 26 letters of the Latin alphabet whose ASCII values are in the range 97-122 for the lower case letters, and in the range 65-90...

  • For this c++ assignment, Overview write a program that will process two sets of numeric information....

    For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....

  • package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task...

    package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task #1 before adding Task#2 where indicated. */ public class NumericTypesOriginal { public static void main (String [] args) { //TASK #2 Create a Scanner object here //identifier declarations final int NUMBER = 2 ; // number of scores int score1 = 100; // first test score int score2 = 95; // second test score final int BOILING_IN_F = 212; // boiling temperature double fToC;...

  • 11.3 LAB: Convert String to Cyphertext cstring mplement the following (Called a Ceasar Cypher, since it...

    11.3 LAB: Convert String to Cyphertext cstring mplement the following (Called a Ceasar Cypher, since it was used in Ceasar's time) using this function prototype in the same file char cypher (string str, int rotate); The idea is that you will declare a variable of type string and give it a value in main. Then pass it into the cypher function. Cypher will create a cstring by copying the str to a new char* of size str.size). Remember that you...

  • QUESTION 1 Which statement results in the value false? The value of count is 0; limit...

    QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count == 0)&&(limit < 20) (count != 0)||(limit < 20) (count == 0)&&(limit < 20) 10 points    QUESTION 2 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b = 2, c = 5 if (a > b) a = 4; if (...

  • You need to write scripts for all problems. Each script should contain the comments on each...

    You need to write scripts for all problems. Each script should contain the comments on each line. You also need to publish your scripts to pdf files. 1. (Chapter.1) Store a number with a decimal place in a double variable (the default). Convert the variable to type int32 and store the result in a new variable. (10pts) 2. (Chapter.1) Create a variable ftemp to store a temperature in degrees Fahrenheit F). Convert this to degrees Celsius C) and store the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT