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
viktelen [127]
3 years ago
5

Write a program that prompts the user to enter the number of integer numbers you need to enter, then ask user to enter these int

eger numbers. Your program should contain an indexOfLargestElement method, which is used to return the index of the largest element in an array of integers.
Computers and Technology
1 answer:
nadya68 [22]3 years ago
8 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 Scanner ob = new Scanner(System.in);

 System.out.println("How many numbers? ");

 int n = ob.nextInt();

       int[] arr = new int[n];  

 for (int i=0; i<n; i++) {

     System.out.print("Enter the number: ");

     arr[i] = ob.nextInt();

 }

    System.out.println(indexOfLargestElement(arr));

}

public static int indexOfLargestElement(int[] arr) {

    int max = arr[0];

    int maxIndex = 0;

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

        if (arr[i] >= max) {

            max = arr[i];

            maxIndex = i;

        }

    }

    return maxIndex;

}

}

Explanation:

Create a method called indexOfLargestElement that takes one parameter, an array

Initialize the max and maxIndex

Create a for loop iterates throgh the array

Check each element and find the maximum and its index

Return the index

Inside the main:

Ask the user to enter how many numbers they want to put in array

Get the numbers using a for loop and put them inside the array

Call the indexOfLargestElement method to find the index of the largest element in the array

You might be interested in
Create a web page for a fictitious company: Widgets Inc. has hired you to make a mock-up for their new website. They are on a bu
lina2011 [118]

Answer:

.20%

Explanation:

4 0
2 years ago
Consider the recursive method whose definition appear below. Why? public static String mysteryString (String s){ if(s.length()==
Marizza181 [45]

Answer:

retupmoc

Explanation:

1.) Anwser will be retupmoc

because

public static String mysteryString(String s){

if(s.length() == 1){

return s;

}

else{

return s.substring(s.length() -1) + mysteryString(s.substring(0, s.length()-1));

}

}

In this program input is "computer" . So the function mysteryString(String s) it does

return s.substring(s.length() -1) + mysteryString(s.substring(0, s.length()-1));

so when it enters the first time ??s.substring(s.length() -1) and it will be give you 'r' then it calls the function recursively by reducing the string length by one . So next time it calls the mysteryString function with string "compute" and next time it calls return s.substring(s.length()-1)? + mysteryString(s.substring(0,s.length-1)) so this time it gives "e" and calls the function again recursively . It keeps on doing till it matched the base case.

so it returns "retupmoc".

6 0
3 years ago
_______ is a variation of phishing that uses voice communication technology to obtain the information the attacker is seeking.
Zanzabum
It's voice phishing but it's also sometimes referred to as vishing 
4 0
2 years ago
Which wireless security methods uses a common shared key configured on the wireless access point and all wireless clients?
Korolek [52]

Answer:

WEP, WPA Personal, and WPA2 personal, these are the wireless security method which are used common shared key configured on the wireless access point and wireless clients. WEP is the wired equivalent privacy and WPA stands for wifi protected access.

These are the wireless security protocols, which basically provide the wireless security to the system. Wireless network are transmitted within the range for every direction. WPA modern application used the pre shared key system and this system are developed for link the device to the access point easily.

4 0
3 years ago
Write a C++ program to grade the answers to a true-false quiz given to students in a course. The quiz consists of 5 true-false q
Eddi Din [679]

The quiz program is an illustration of loops and conditional statements

  • Loops are used to perform repetition
  • Conditional statements are used to make decisions

<h3>The quiz program</h3>

The quiz program written in C++, where comments are used to explain each action is as follows:

#include <iostream>

using namespace std;

int main(){

   //This prints the instruction

   cout<<"Enter T/t for True; F/f for False\n";

   //This initializes the question

   string questions[5] = { "Q1", "Q2", "Q3", "Q4", "Q5"};

   //This initializes the correct options

   char options[5] = { 'T','T','F','F','T'};

   //This declares the user response

   char opt;

   //This initializes the score to 0

   int score = 0;

   //This loop is repeated 5 times

   for (int i = 0; i < 5; i++){

       //This prints the current question

       cout << i + 1 <<". "<<questions[i]<<"\nAnswer: ";

       //This gets the user response

       cin>>opt;

       //If the user response is correct

       if(toupper(opt) == options[i]){

           //The score is incremented by 2

           score+=2;

       }

   }

   //This prints the total score

   cout<<"Score: "<<score;

   return 0;

}

Read more about loops at:

brainly.com/question/19347842

7 0
1 year ago
Other questions:
  • Is the movie IT really that scary ? Rate between 1-10, 10 being I had nightmares
    6·1 answer
  • Today's Apple Mac computers run with the same I-Ternal hardware as the Windows based PC true or false
    5·1 answer
  • You can send emails to individuals from your address book.<br><br> True<br> False
    12·1 answer
  • कम्प्यूटर में एक समस्या को ठीक करने के लिए एक कार्यक्रम या कोनफीगरेशन परिवर्तन के बाद किए जाते हैं
    5·1 answer
  • Which person would be the best fit for a career in the Information Technology field?
    6·2 answers
  • Which components are involved with input? Output? Processing? Storage?
    15·2 answers
  • Davids family took him to a hospital as he was suffering from a sericous ailment
    8·1 answer
  • What is connectivity?
    15·2 answers
  • write a program which prompts the user for a celsius temperature, convert the temperature to fahrenheit, and print out the conve
    6·1 answer
  • To set up scenarios,then set up a list, then set up the reference cell. to set up the cells that display the output results from
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!