Question

java Write a single Java statements to accomplish each of the following: a) Displaythevalueoftheseventhelementofcharacterarraych. b) Considering...

java

Write a single Java statements to accomplish each of the following:

  1. a) Displaythevalueoftheseventhelementofcharacterarraych.

  2. b) Considering “Scanner in = new Scanner (System.in);”, input a value into

    element 5 of one-dimensional double array nums.

  3. c) Initialize each of the four elements of the one-dimensional integer array test to 7.

  4. d) Declare and create an array called table as a float array that has four rows and three columns.

  5. e) Considering the following ArrayList declaration, insert “test” at the fourth position (index 3) in list.
    ArrayList<String> list = new ArrayList<>();

  6. f) Give the method header for method mode that takes two integer arrays freq and answer, and returns a double-precision floating-point result.

  7. g) Considering the following array declaration:
    int[][] numberArray = new int [9][11];

write a statement that assigns 145 to the first column of the last row of this array.

Homework Answers

Answer #1

a)

answer: ch[6];

because the index values starts from 0 to n-1 n is the lenght of the array

for the seventh element the index will be 6 so the answer is ch[6]

b)

nums[4]=in.nextDouble();

becuase to read the 5th element its index will be 4

to read the double element scannerobject.nextDouble() is used to read the double form the user.

Here scanner object is in so in.nextDouble() is used to read the double and it is stored in nums[4]

so the answer is nums[4]=in.nextDouble();

c)

answer:

int[] test={7,7,7,7}

here the lenght of the array is 4.

and each element is 7.

d)

answer:

float[][] table={{1f,2f,3f},{1f,2f,3f},{1f,2f,3f},{1f,2f,3f}};

float is the data type

table is the name of the float array

and there are 4 rows and 3 columns

Note: we are not suposed to answer more than 4 subparts of the question

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
JAVA a. An integer is a "Lucky Number" if it is divisible by 7 or is...
JAVA a. An integer is a "Lucky Number" if it is divisible by 7 or is divisible by 11 and it is in the range 1000 through 4000. Write a Boolean expression that is true if and only if myNum (an int variable) contains a Lucky Number. b. Let a and b represent the length and the width of a rectangle. The length of the diagonal of the rectangle can be calculated by the following mathematical expression. diagonalLength = squareRoot(a...
[Java] I'm not sure how to implement the code. Please check my code at the bottom....
[Java] I'm not sure how to implement the code. Please check my code at the bottom. In this problem you will write several static methods to work with arrays and ArrayLists. Remember that a static method does not work on the instance variables of the class. All the data needed is provided in the parameters. Call the class Util. Notice how the methods are invoked in UtilTester. public static int min(int[] array) gets the minimum value in the array public...
IN JAVA!! You may be working with a programming language that has arrays, but not nodes....
IN JAVA!! You may be working with a programming language that has arrays, but not nodes. In this case you will need to save your BST in a two dimensional array. In this lab you will write a program to create a BST modelled as a two-dimensional array. The output from your program will be a two-dimensional array.   THEN: practice creating another array-based BST using integers of your choice. Once you have figured out your algorithm you will be able...
IN JAVA Methods*: Calorie estimator Write a method ActivityCalories that takes a string indicating an activity...
IN JAVA Methods*: Calorie estimator Write a method ActivityCalories that takes a string indicating an activity (sit, walk, jog, bike, swim) and duration in minutes (integer), and returns the estimated calories expended (double). Calories per minute for a 150 lb person (source): sit: 1.4 walk: 5.4 run: 13.0 bike: 6.8 swim: 8.7 If the input is sit 2, the output is 2.8 Hints: Use an if-else statement to determine the calories per minute for the given activity. Return the calories...
JAVA please Arrays are a very powerful data structure with which you must become very familiar....
JAVA please Arrays are a very powerful data structure with which you must become very familiar. Arrays hold more than one object. The objects must be of the same type. If the array is an integer array then all the objects in the array must be integers. The object in the array is associated with an integer index which can be used to locate the object. The first object of the array has index 0. There are many problems where...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
Java Programming In this lab students continue to write programs using multiple classes. By the end...
Java Programming In this lab students continue to write programs using multiple classes. By the end of this lab, students should be able to Write classes that use arrays and ArrayLists of objects as instance variables Write methods that process arrays and ArrayLists of objects Write getter and setter methods for instance variables Write methods using object parameters and primitive types Question- class StringSet. A StringSet object is given a series of up to 10 String objects. It stores these...
I am a beginner when it comes to java codeing. Is there anyway this code can...
I am a beginner when it comes to java codeing. Is there anyway this code can be simplified for someone who isn't as advanced in coding? public class Stock { //fields private String name; private String symbol; private double price; //3 args constructor public Stock(String name, String symbol, double price) { this.name = name; this.symbol = symbol; setPrice(price); } //all getters and setters /** * * @return stock name */ public String getName() { return name; } /** * set...
THIS IS FOR JAVA I have to write a method for a game of Hangman. The...
THIS IS FOR JAVA I have to write a method for a game of Hangman. The word the user is trying to guess is made up of hashtags like so " ###### " If the user guesses a letter correctly then that letter is revealed on the hashtags like so "##e##e##" If the user guesses incorrectly then it increments an int variable named count " ++count; " String guessWord(String guess,String word, String pound) In this method, you compare the character(letter)...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that will provide the same function. Char grade; String tstmsg; if (grade == ‘A’) {   tstmsg = “Excellent”; } else if (grade == ‘B’) {   tstmsg = “Good”; } else if (grade == ‘C’) {   tstmsg = “OK”; } else {   tstmsg = “Study More”; } 2.Write the following for statement as a while statement. for (k = 0; k < 3; k++) {   System.out.println...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT