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
Nadya [2.5K]
3 years ago
5

Write a method that finds the cheapest name of apples, and returns back a String stating what the apple name is and how much it

costs. The method should take two arrays as two parameters (you do not need to make a two dimensional array out of these arrays).
Computers and Technology
1 answer:
Korolek [52]3 years ago
7 0

The question is incomplete! Complete question along with answer and step by step explanation is provided below.

Question:

Two arrays are given:  

String apples[] = {"HoneyCrisp", "DeliciousRed", "Gala", "McIntosh",  "GrannySmith"};

double prices[] = {4.50, 3.10, 2.45, 1.50, 1.20};

Write a method that finds the cheapest name of apples, and returns back a String stating what the apple name is and how much it costs. The method should take two arrays as two parameters (you do not need to make a two dimensional array out of these arrays).

Answer:

The complete java code along with the output is prrovided below.

Java Code:

public class ApplesCheap

{

   public static String Cheapest(String apples[], double prices[])

 {

       int temp = 0;

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

    {

         if (prices[i] < prices[temp])

          {

               temp = i;

           }

       }

       return apples[temp];

   }

public static void main(String[] args)

{

// define the array of apple names and their prices

  String apples[] = {"HoneyCrisp", "DeliciousRed", "Gala", "McIntosh", "GrannySmith"};

  double prices[] = {4.50, 3.10, 2.45, 1.50, 1.20};

// print the cheapest apple by calling the function Cheapest

  System.out.println("The cheapest apple is: " + Cheapest(apples, prices));

   }

}

Output:

The cheapest apple is: GrannySmith

You might be interested in
What is programming blocks?
charle [14.2K]

Answer:

In computer programming, a block or code block is a lexical structure of source code which is grouped togethe

Explanation:

3 0
3 years ago
Consider the code below. Note that the catch statements in the code are not implemented, but you will not need those details. As
Dmitriy789 [7]

Missing Part of Question

An exception raised by the instruction in i3 would be caught by the catch statement labeled?

Answer:

e3 and e4.

Explanation:

The instruction tag i3 points to the following code segment

a[++i] = (double) (1 / x); // i3

The code segment above performs arithmetic operation (double)(1/x)

And then assigns the value of the arithmetic operations to an array element a[++I]

It's possible to have one or both of the following two exceptions.

1. Error in Arithmetic Operation

2. Index of Array out of bound

These are both represented in exception tags e3 and e4

catch (ArithmeticException ex) {...} // e3

catch (ArrayIndexOutOfBounds ex) {...} // e4

Exception e3 can arise when the program try to carry out invalid arithmetic operation.

For instance, 1/0 or 0/0.

This will lead to ArithmeticException to be thrown

Exception e4 can arise when the program tries to assign values to an index that's not in an array.

Say, the total index in a given array a is 5.

The index of this array is 0 to 4; i.e. a[0] to a[4]

The moment the program tries to assign values to array element other than the ones I listed above (e.g a[5]) ArrayIndexOutOfBounds exception will be thrown

6 0
3 years ago
Frrrrrrrrrrreeeeeeeeee brainliest for u
sukhopar [10]

Answer:

Yay I want brainliest

Explanation:

5 0
3 years ago
Read 2 more answers
The ______ sets rules for both the transport of data packets and the addressing system for a network such as the ARPANET
Phantasy [73]

The tool that sets rules for both the transport of data packets and the addressing system for a network such as the ARPANET is called; Protocol

<h3>Understanding Protocols</h3>

In computer systems communications, a protocol is defined as a set of rules and regulations that allow a network of nodes to transport and receive data information.

Now, each transport layer in a system of network such as ARAPNET will always have a protocol set such as TCP and IP.

Read more about internet protocols at; brainly.com/question/17820678

3 0
2 years ago
My messaging system is messed up. It keeps saying I'm getting messages but then it says nothing new in my inbox. I'm confused- H
denpristay [2]

Answer:

hey! that happens to me too!

Explanation:

tbh i just think its whenever you comment on something and someone answers, that appears... but i could be wrong.

lol :)

4 0
3 years ago
Read 2 more answers
Other questions:
  • Which technological innovations along history allowed the appearance of the computer
    9·2 answers
  • Given that a method receives three parameters a, b, c, of type double, write some code, to be included as part of the method, th
    8·1 answer
  • HTML code must be enclosed in the _______ (angle brackets) so the browser can tell the difference between code and content you w
    6·2 answers
  • 3. The invention of the transistor was important to the development of computers because it
    5·1 answer
  • What is the target audience for this poster?
    5·2 answers
  • In the legend of sleeping Hallow what does Ichabod Crane fear the most
    13·2 answers
  • I NEED HELP PLEASE!! I just wanted to upgrade my i3 processor to an i7. I bought new hardware (motherboard, fan, etc) and now th
    5·1 answer
  • Witch of the following is a valid why a scientist might a scientific theory
    13·1 answer
  • Which letter is located at position (7,4) on this coordinate grid? A) B) C) D)
    12·1 answer
  • 0 % 3? Is it 0 or undefined? (% is mod)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!