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
andreev551 [17]
3 years ago
6

2. Using the Enhanced for Statement, write an application that uses an enhanced for statement to sum the double values passed by

the command-line arguments. [Hint: Use the static method parseDouble of class Double to convert a String to a double value.] This is sample run of your program: The·sum·of·the·double·values·passed·in·from·the·command·line·is·0.0↵

Computers and Technology
1 answer:
solniwko [45]3 years ago
5 0

Answer:

Here is the program:

public class DoubleValue

{ public static void main(String[] args) { //start of the main function

 double sum = 0.0;  // initialize double type sum by 0.0

//for statement to sum the double values passed by the command-line //arguments

       for (String str : args)        {  

         sum += Double.parseDouble(str);  

//returns double representation of the passed str argument and takes the //sum of these double values         }

       System.out.printf("The sum of the double values passed in from the command line is %.1f\n", sum);  }  }      

//prints the above message with output 0.0                                  

Explanation:

The above program has a static method parseDouble of class Double to convert a string str to a double value and the for statement is used to sum the double values passed by command line arguments. This sum is stored in sum variable and is displayed in the output. The program along with its output is attached.

If you want to get the input from the user you can use the following code. Just use the Scanner class to take input from the user.

import java.util.Scanner;

public class DoubleValue

{ public static void main(String[] args) {

//two string type variables

 String str1;

               String str2;

//scans and reads input from user

Scanner input = new Scanner(System.in);

System.out.println("Enter value of str1: ");

str1 = input.next();

System.out.println("Enter value of str2: ");

str2 = input.next();

double sum = 0.0;

//sum double values and parseDouble function is used to convert string to //double value

sum += Double.parseDouble(str1) + Double.parseDouble(str2);

System.out.printf("The sum of the double values passed in from the command line is %.1f\n", sum); } }  //prints result of the sum

You might be interested in
6. What is saddle-stitch binding?
kifflom [539]
Commonly known as book stapling, ‘saddle stitched’ is one of the most popular binding methods. The technique uses printed sheets which are folded and nestled inside each other. These pages are then stapled together through the fold line. Saddle stitched binding can be applied to all book dimensions and both portrait and landscape orientation.
5 0
3 years ago
Read 2 more answers
Linotype is similar to letterpress since both utilize lead type. The difference is that in a linotype, the type is cast into ful
Maru [420]

Answer:

I think it would be.

A-Metal-cast pouring system

<h2>I hope it helps</h2>

8 0
4 years ago
Identify the components of documents merging
Lena [83]
There are 3 components of documents merging :

- input 1  , which contain the data source

- Input 2, which contain the main document

and

- Output 3, which contained the merged the documents
8 0
3 years ago
A metacharacter is a character that has a special meaning assigned to it and is recognized as part of a scripting or programming
nydimaria [60]

Answer:

The answer is "Option a"

Explanation:

Meta-character is a unique character, which is used in the system or information area, that provides information about the other characters. This type of character is used in both command-line and programming.  

  • It has a particular meaning and should be prevented for reasons except for its particular importance.
  • It attempts in the algorithmic technique to view all character as a fundamental ASCII instead of a specific purpose.
3 0
3 years ago
An example of a target group might be people who:
Pie
C. They have something in common: they don't have access to social media.
7 0
3 years ago
Read 2 more answers
Other questions:
  • The actual database of Active Directory shared resources is stored on one or more computers designated as:
    6·1 answer
  • Which data type structures best for insersion/ removal - Stack, linked list, queue?
    15·1 answer
  • How can you prevent the flash from going off no matter how much light there is iready
    7·1 answer
  • 1.the following code example would print the data type of x, what data type would that be?
    12·1 answer
  • Anyone Free to Talk??????? I'm Bored :(
    6·2 answers
  • Does anyone know how to fix this? Everytime i make a new page it only types in the middle of the page. I want to type at the top
    11·1 answer
  • Select all the correct answers.
    14·2 answers
  • Re:
    15·1 answer
  • Why can’t a computer use source code
    5·2 answers
  • Access your Practice Lab titles Access your exercise content Reports and files Access your settings Access help and support Comp
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!