Java Reference
In-Depth Information
array, cars , of 10 components of type int to store the number of cars sold
by each salesperson.
int [] cars = new int [10];
Write the code so that the number of cars sold by each salesperson is stored in the array
cars , output the total numbers of cars sold at the end of each month, and output the
salesperson number selling the maximum number of cars. (Assume that data is in the
file cars.dat and that this file has been opened using the Scanner object inFile .)
24. What is the output of the following program?
import java.util.*;
public class Exercise24
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
int count;
int [] alpha = new int [5];
alpha[0] = 5;
for (count = 1; count < 5; count++)
{
alpha[count] = 5 * count + 10;
alpha[count - 1] = alpha[count] - 4;
}
9
System.out.print("List elements: ");
for (count = 0; count < 5; count++)
System.out.print(alpha[count] + " ");
System.out.println();
}
}
25. What is the output of the following program?
public class Exercise25
{
public static void main(String[] args)
{
int [] one = new int [5];
int [] two = new int [10];
for ( int j = 0; j < 5; j++)
one[j] = 5 * j + 3;
System.out.print("One contains: ");
for ( int j = 0; j < 5; j++)
System.out.print(one[j] + " ");
System.out.println();
Search WWH ::




Custom Search