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
Difference between alt tab and windows tab
Kryger [21]
Alt+Tab switches between windows instantly while Windows+Tab displays all currently active windows.
Hope this helps :D
7 0
3 years ago
What is the difference between images and pictures
julia-pushkina [17]
An image is a representation of a person or thing but a picture is a painting or drawing
6 0
3 years ago
Students who interact online with others from different cultures should remember that
aliya0001 [1]

Answer:

they are dealing with people, not computers.

8 0
4 years ago
Read 2 more answers
Informs the network interface card to pass packets sent to that address to the ip stack so their contents can be read, and tells
Lesechka [4]
The answer to this question is Registration
Registration on the network interface will allow computer users all around the world to access a certain information stored within a certain address in that network which most people know as a website.
Today, to do a network registration, people just need to contact a hosting service that will take care of everything for us, and we just need to provide the content.


6 0
3 years ago
Question 19 :A user needs the video capability in his computer upgraded to support a new graphics application. The computer incl
elena-s [515]

Answer:

The onboard video card should be disabled in the BIOS. After you disable the onboard video card in the BIOS, it will no longer function.

Explanation:

Since in the question a user wants to upgrade for new graphics application and also the computer involves the onboard video card and a new video card is installed in the computer now you want to disabled it

So this can be done in the BIOS i.e basic input output system which is to be used for rebooting the computer system

And after disabled it, you cannot used.

3 0
3 years ago
Other questions:
  • What is the problem we can't build shelter on mars ?
    6·1 answer
  • Ross has to create a presentation for his class but can't decide on a topic. What should he do?
    9·2 answers
  • Why is it important to try to make financial decisions without emotions.
    12·2 answers
  • 6. 6. While printing a document, what are the options available in the Settings section?
    9·1 answer
  • Which of the following domestic appliances does not use a magnet?
    10·2 answers
  • PLS HELP
    5·1 answer
  • 29. Write a program that asks to input any ten numbers and displays sum of them​
    11·1 answer
  • Need help ASAP <br><br> Thankss + BRAINLIST only for correct answers
    10·1 answer
  • Targeted advertising, in which advertisements are shown to individuals based on past purchases, web searches or other demographi
    9·1 answer
  • Why must the image be reduced when the field of view is widened to take in more of the scene?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!