Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java The program has to be similar to this: import java.util.*; import java.io.*; public class HelloWorld{ public static void rcConvert(int[][] ar1, int[][] ar2, int r,

Java

The program has to be similar to this:

import java.util.*; import java.io.*; public class HelloWorld{ public static void rcConvert(int[][] ar1, int[][] ar2, int r, int c){ int i,j; for(i=0; i

public static void main(String []args){ int i, j; //for iterating thru the array File inF = new File("file1"); Scanner in = null; try{ in = new Scanner(inF); } catch (Exception e) {System.out.println("Error: " + e);} int r = in.nextInt(); int c = in.nextInt(); //read rows & columns int[][] arr1 = new int[r][c]; //declare the required 2D array int[][] arr2 = new int[c][r]; //declare another array for(i=0; i

What i mean is that it has to follow like the patter trying to use short coding instead of heavy code(lot of lines of code)

image text in transcribed

1a) Create file, file1, with the following values: Java Program 10 1 2 3 5 -4 2 16 3 2 1b) Write a program in Java to do the following: Open "file1" and read the first integer into variable n which is supposed to indicate the dimension of the one-dimensional array whose values are given in the file after the first integer. -Create a one-dimensional array of size n. Populate the one-dimensional array created in the previous step by reading values from file1: 1 2 3 5 4 2 1 6 3 2 Write a function, neg, using a for loop to negate all the values such that the array appears as follows: Write a function, storelnFile, to store the modified array in file file2 Call functions neg and storelnFile from the main program to negate the array elements and store the modified array in file2. Use structures like functions, while, do while, switch, for, and if where needed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago

Question

What are the skills of management ?

Answered: 1 week ago

Question

2. Why has the conflict escalated?

Answered: 1 week ago