Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Commandline arguments

Have Programming Question? Ask it here!
 
 
 


Venkat
Commandline arguments
1 Answer(s)      5 years and a month ago
Posted in : Java Beginners



Advertisement
View Answers

June 24, 2009 at 10:47 AM


Hi Friend,

Try the following code:

import java.util.*;
public class SumAndAverage{
public static void main (String [] arg) {
Scanner scan = new Scanner (System.in);
int [] numbers = new int [10];
int sum=0;
System.out.print("Enter 10 numbers");
for (int i=0; i<numbers.length; i++) {
numbers[i]=scan.nextInt ();
sum+=numbers[i];
}
System.out.println("Sum of Numbers: "+sum);
System.out.println("Average of Numbers: "+sum/10);
}
}
Hope that it will be helpful for you.

Thanks


Related Tutorials/Questions & Answers:
Commandline arguments - Java Beginners
Commandline arguments  hi!My question is: Write a program to store the marks of 10 students in an array.Accept these marks as command line arguments and display their sum and average. Please respond as soon as possible.  
how to pass command line arguments in ant
how to pass command line arguments in ant  How to pass runtime values ie commandline arguments to a program written in java using ant tool
Advertisements
JavaScript pass arguments
JavaScript pass arguments   How to pass dynamic arguments to the functions in JavaScript
Printing Command Line arguments in JRuby
# Printing commandline arguments 0.upto( "#{ARGV.length}".to_i... Printing Command Line arguments in JRuby... we will discuss about printing command line arguments in JRuby program. We can
mysql_connect arguments
mysql_connect arguments   How many arguments a mysql_connection... takes three arguments Server - localhost Username - admin Password - 1admin And if the given arguments are correct it will connect to the database and print
arguments evaluation - Java Beginners
arguments evaluation   i am not sure about the evaluation order of arguments in java. can any one tell me that arguments in java is evaluated left... the arguments evaluated in C C
Command line arguments
Command line arguments  Please explain me what is the use of "command line arguments" and why we need to use
Passing Arguments. - Java Beginners
Passing Arguments.  Hi, im new in doing this passing arguments and calling methods. Can you please see that y im not getting the answer as the question says to do. Thanks Question:Write a method that is passed two arguments
function arguments in java
function arguments in java  function arguments in java   Command line argument in Java import java.util.*; public class SumAndAverage...); } } In the above code, the values of i and j are function arguments
COMMAND LINE ARGUMENTS
COMMAND LINE ARGUMENTS  JAVA PROGRAM TO ACCEPT 5 COMMAND LINE ARGUMENTS AND FIND THE SUM OF THAT FIVE.ALSO FIND OUT LARGEST AMONG THAT 5   Hi Friend, Try the following code: import java.util.*; class
Command line arguments
Java application can accept any number of arguments directly from the command line. The user can enter command-line arguments when invoking the application. When running the java program from java command, the arguments are provided
List out different arguments in PHP header function?
List out different arguments in PHP header function?   List out different arguments in PHP header function
function error too many input arguments
function error too many input arguments  function error too many input arguments
how many max. arguments we pass to the any function ? how many max. arguments we pass to the any function ?
how many max. arguments we pass to the any function ? how many max. arguments we pass to the any function ?   how many max. arguments we pass to the any function
JavaScript Array Arguments
JavaScript Array Arguments     ... which enables the programmer to tell how many arguments (or variables) are passed... in the function. In the given example, we have passed the arguments in the following way
Command Line Arguments in Java Program
Command Line Arguments in Java Program       Java application can accept any number of arguments directly from the command line. The user can enter command-line arguments when
Java program to get the Command Line Arguments
Java program to get the Command Line Arguments... arguments as they are provided on the console. In this example program our program takes arguments from the console and print it on the console. In our example
how many max. arguments we pass to the any function ?
how many max. arguments we pass to the any function ?   how many max. arguments we pass to the any function
please tell me about command line arguments in java?
please tell me about command line arguments in java?  please tell me about command line arguments in java?   Hi Friend, The command-line arguments are the arguments which are sent to the program being called. You can
please tell me about command line arguments in java?
please tell me about command line arguments in java?  please tell me about command line arguments in java?   Hi Friend, The command-line arguments are the arguments which are sent to the program being called. You can
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
how to calculate addition of two distances in feets and inches using objects as functions arguments
how to calculate addition of two distances in feets and inches using objects as functions arguments  how to calculate addition of two distances in feets and inches using objects as functions arguments in java
Command Line Arguments in Java
Command Line Arguments in Java The ongoing Java application can accept any number of arguments from the command line but it is command line argument, which.... Suppose program named CmndLineArguments that accept command line arguments
PHP Function Arguments
Arguments of User Defined PHP Functions: In PHP we can pass the data to functions via the argument list by value, by reference, and default arguments. These arguments are local to the function and after performing some calculation
Passing Command Line Arguments
Passing Command Line Arguments       In this example we are going to learn how we can pass values on command line argument . We are taking a sequence
Command line argument in java
arguments at the time of running the application , after the class name. Java allow... Classname argument1 argument 2 argument3 .... Example: java Commandline Welcome to Rose India public class Commandline { public static void main(String
Spring Constructor arg type
Constructor argument type matching In this example you will see how to inject the arguments into your bean by matching the constructor arguments type. ConstructorInjection.java package 
Add Two Numbers in Java
with command prompt arguments provided by the user. We will access these arguments and print the addition of those numbers. In this example, args.... These passed arguments are of String types so these can't be added as numbers
Args tutorial
Args tutorial Are you looking for Args tutorial in Java Technolog? Args represents the command line arguments in the Java program. You can pass any number of the parameters through the args variable. In this example we will show how
&lt;APPLET&gt; Tag Parameters: The &lt;PARAM&gt; Tag
arguments are to applications. These parameters allow the user to customize
U - Java Terms
U - Java Terms       Java util Date The class Date in "java.util" package represents date and time. It's no arguments constructor
Spring Constructor arg index
Constructor Arguments Index In this example you will see how inject the arguments into your bean according to the constructor argument index. ConstructorInjection.java  package 
JPA Substring() Function
() function. The substring() function returns the some part of string arguments. It takes three arguments. First is string argument that have to be concatenate
MySQL Coalesce
MySQL Coalesce       In this section, you will learn about MySQL Coalesce. It selects the first non-null value of its arguments. Syntax: coalesce(value,..): It returns the first
JavaScript elementFromPoint method
JavaScript elementFromPoint method       JavaScript method elementFromPoint returns the presented element at the specified coordinate position given in the arguments
JPA Upper Function
JPA Upper Function       In this section, you will learn about the JPA Upper() function. This function returns upper-case of the specified string arguments. JPA Upper
Generic Methods
a single Generic method which can be called by passing arguments of different...(,)  The passed argument(known as actual type arguments) replaces...;T> acts as placeholder for the passed arguments to the Generic method "
How To Read String From Command Line In Java
is entered after giving the name of the class. There is no limit of arguments giving from the command line. Command line arguments are passed... Java source code, one will explain that how any number of arguments can
Gradient Background iPhone
Gradient Background iPhone In this tutorial, we are going to show you how to change UINavigationBar Color in Gradient. This example is similar to our previous one, only difference is that this time we are passing four arguments
Methods in Objective c
arguments and return types. Argument can be declared after " : " sign
Introduction to Collection Algorithms
( ) method. For example, the following program prints the arguments (the arguments, given through command line) of a  List...: C:\nisha>java SortDemo this is a commandline argument [a, argument
SubText Plugin
SubText Plugin       Arguments for Aspect Oriented Programming are also relevant... precisely the specified type, followed by a full method name with no arguments
Client Socket Information
of the Socket class passing two arguments as hostName and TIME_PORT
Finalize Method in Java
no value and no arguments but can be overridden by any class. The finalize method
 

 

 

DMCA.com