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
il63 [147K]
2 years ago
14

Array Basics pls help

Computers and Technology
1 answer:
posledela2 years ago
5 0

Answer:

import java.util.Random;

class Main {

 static int[] createRandomArray(int nrElements) {

   Random rd = new Random();

   int[] arr = new int[nrElements];

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

     arr[i] = rd.nextInt(1000);

   }

   return arr;

 }

 static void printArray(int[] arr) {

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

     System.out.println(arr[i]);

   }

 }

 public static void main(String[] args) {

   int[] arr = createRandomArray(5);

   printArray(arr);

 }

}

Explanation:

I've separated the array creation and print loop into separate class methods. They are marked as static, so you don't have to instantiate an object of this class type.

You might be interested in
What is a alt key and how does it work
Sever21 [200]
A key on a keyboard that when pressed at the same time as another key gives the second key an alternative function.
4 0
4 years ago
Read 2 more answers
Write a program that asks for a password and then verifies that it meets the stated criteria. • If the password meets the criter
inessss [21]

Missing Details in Question

The password criteria are not stated. For this program, I'll assume the following

  • Password must contain at least 1 capital letter
  • Password must contain at least 1 small letter
  • Password must contain at least 1 digit
  • Password must be at least 8 characters

See Attachment for Source File "MyName-Hwrk10A.cpp"

Answer:

// Comment explains difficult lines

#include<iostream>

#include<cstring>

#include<cctype>

using namespace std;

int main()

{

//Enter your name here

int k,l,m;

/*

Integer variables k,l and m are used to count the number of  

capital letters small letters and digits in the input string (password)

*/

//Initialize them to 0

k=0;l=0;m=0;

int length;

string pass;

cout<<"Password: ";

cin>>pass;

//Calculate length of input string

length = pass.length();

//The following variable is declared to determine if the input string meets criteria

int det = 0;

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

{

 if(isupper(pass[i])){ k++;}

 if(islower(pass[i])){ l++;}

 if(isdigit(pass[i])){ m++;}    

}

if(k==0)

{

cout<<"Password doesn't contain capital letters "<<endl;

det++;

}

if(l==0)

{

cout<<"Password doesn't contain small letters "<<endl;

det++;

}

if(m==0)

{

cout<<"Password doesn't contain digit "<<endl;

det++;

}

if(length<8)

{

cout<<"Length of password is less than 8 "<<endl;

det++;

}

if(det == 0)

{

 cout<<"Password meets requirements "<<endl;

}    

 return 0;

}

Download cpp
4 0
3 years ago
A multinational pharmaceutical company used a saffron trident in a promotional campaign for one of its drugs in India. The saffr
Vera_Pavlovna [14]
Answer : Encoding

Explanation : Encoding refers to correctly coding the message so that the receiver gets the clear message without feating any misunderstanding.
5 0
3 years ago
​to add notes or comments, insert a comment tag using the syntax _____.
Aneli [31]
The needed syntax would be:
<!--comment-->
Hope I could be of assistance! ;)
4 0
4 years ago
Read 2 more answers
Which option of ms-word is used o represent data in an organised manner?
tekilochka [14]
Use the charting features of Word 2007 and Excel 2007 to present<span> your </span>data<span> in a pie, line, </span>
3 0
3 years ago
Other questions:
  • A Hierarchy Custom Setting stores a specific URL for each profile in Salesforce. Which statement can a developer use to retrieve
    5·1 answer
  • Would you recommend the 4a generations of computers to a friend
    5·1 answer
  • If an additional term relates to payment, quality, quantity, price, time, and place of delivery, the CISG considers the added te
    12·1 answer
  • Which of these identifies the intersection of row 16 and column D?
    14·1 answer
  • 4.3 Code Practice<br> edhisve
    13·1 answer
  • A company is concerned that hackers may gain access to its computer system or that it may be
    11·1 answer
  • 1. What are the main uses for Protein in the body?
    13·2 answers
  • What's the use of computer?Where are they used?​
    6·2 answers
  • Which of the following file formats allows you to share and save documents
    5·1 answer
  • Decades of research throughout the world have found a _____ correlation between academic achievement and socioeconomic status, l
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!