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
SashulF [63]
3 years ago
12

Code a complete Java program to load and process a 1-dimensional array.

Computers and Technology
1 answer:
zepelin [54]3 years ago
6 0

Answer:

Here you go.Consider giving brainliest if it helped.

Explanation:

import java.io.*;//include this header for the file operation

import java.util.*;//to perform java utilities

import javax.swing.JOptionPane;//needed fro dialog box

class Driver{

  public static void main(String args[]){

      int wages[]=new int[15];//array to hold the wages

      int index=0;

      try{

          //use try catch for the file operation

          File file=new File("wages.txt");

          Scanner sc=new Scanner(file);//pass the file object to the scanner to ready values

          while(sc.hasNext()){

              String data=sc.nextLine();//reads a wage as a string

              String w=data.substring(1);//remove the dollar from the string data

              wages[index++]=Integer.parseInt(w);//convert the wage to int and store it in the array

          }

          sc.close();//close the scanner

      }catch(FileNotFoundException e){

          System.out.println("Error Occurrred While Reading File");

      }

     

      //sort the array using in built sort function

      Arrays.sort(wages);

      //print the wages

      System.out.println("Wages of 15 person in ascending order:");

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

          System.out.print("$"+wages[i]+" ");

      }

      //call the increases wages method

      wages=increaseWages(wages);//this method return the updated wages array

     

  }

 

  //since we can call only static methods from main hence increaseWages is also static

  public static int[] increaseWages(int wages[]){

      //increase the wages

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

          wages[i]+=500;

      }

     

      //print the new wages

      int sum=0;

      System.out.println("\n\nNew wages of 15 person in ascending order:");

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

          sum+=wages[i];//sums up the new wages

          System.out.print("$"+wages[i]+" ");

      }

     

      //display the summation of the new wages in a dialog box

      JOptionPane.showMessageDialog(null,"Total of new wages: "+sum);

      return wages;

  }

}

You might be interested in
We will pass in a value N. Ouput every even value between 0 and N. Tip: you may remember the modulo operator. 10 % 3 returns the
Taya2010 [7]

Answer:

def odd_even(N):

   for number in range(0, N+1):

       if number % 2 == 0:

           print(str(number) + " is even")

       elif number % 2 == 1:

           print(str(number) +" is odd")

odd_even(5)

Explanation:

- Create a method called odd_even that takes one parameter, N

- Initialize a for loop that iterates through 0 to N

Inside the loop, check if module of the number with respect to 2 is equal to 0. If yes, print it as even number. If module of the number with respect to 2 is equal to 1, print it as odd number

Call the method

6 0
3 years ago
Name 3 examples of operating system software that are not Windows based.
anyanavicka [17]
Ubuntu, Linux, and Mint
4 0
4 years ago
APCS A: I'm reviewing an old ap test and can't get past this problem:
yaroslaw [1]

Answer:

The answer is "Option A"

Explanation:

Following are the complete code to these question:

public class Arr//defining a class-Arr

{

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

{

        int [][] numbers={{1, 2, 3},{4,5,6}}; //defining 2D array numbers

for(int[] row : numbers) //use for loop that holds all array value into 1D  array

{

for (int n: row)//defining n variable that holds row array values  

{

System.out.print (n); //print n variable value

}

}

}

}

The code comment explains its functioning.

7 0
3 years ago
Which of the following is not a factor that affects productivity?
hjlf

<em>The answer is wireless cellular phones. </em>

<em> </em>

<em>Companies use of wireless cellular phones may vary and majority are considered it as optional. Instead of talking via wireless cellular phones, emails and telephone lines conversation are much advisable for cost-effective and formal type of communication process.</em>

5 0
4 years ago
Battery maker Duracell introduced a new product called the Duracell Powermat, which is a wireless charging pad for mobile device
Pachacha [2.7K]

Answer:

The answer is "Option E".

Explanation:

It is also known as the brand stretching, it is a marketing technique where a business selling a brand with a well-designed logo using that same brand name inside another market segment. They find the new item a turn-off, and wrong choices can be described as follows:

  • In option A, It is wrong because it is an existing business model.
  • In option B, It is wrong because it is a brand name.
  • In option C, It is a device that, works on multiple tables, that's why it is incorrect
  • In option D, It is also known as the model, that provides rules to stabilized the firms, that's why it is incorrect
4 0
3 years ago
Other questions:
  • What was the treaty of the Meter
    13·1 answer
  • Branching is so called because <br>​
    5·2 answers
  • A company that hires only American Indians is practicing
    5·2 answers
  • True or False? To use a C++ library function, you must use an #include directive to include the appropriate header file.
    8·1 answer
  • A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never
    7·1 answer
  • We wish to design a decoder, with three inputs, x, y, z, and eight active high outputs, labeled 0, 1, 2, 3, 4, 5, 6, 7. There is
    5·1 answer
  • 17. When looking for information on a web site, what is the easiest method to find that information? The search button The searc
    15·1 answer
  • State the name of each of the storage devices described below.
    14·1 answer
  • Alex has composed a layout with this Image for a magazine. Which rule of composition has Alex applied?
    14·1 answer
  • A computer is the __________ of an attack when it is used to conduct an attack against another computer.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!