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
Ira Lisetskai [31]
3 years ago
10

Write the definition of a method, oddsMatchEvens, whose two parameters are arrays of integers of equal size. The size of each ar

ray is an even number. The method returns true if and only if the even-indexed elements of the first array equal the odd-indexed elements of the second, in sequence. That is if w is the first array and q the second array, w[0] equals q[1], and w[2] equals q[3], and so on.
Computers and Technology
1 answer:
ss7ja [257]3 years ago
8 0

Answer:

public boolean oddsMatchEvens(int[ ] w, int[ ] q) {

   for (int i = 0; i < w.length-1; i+=2) {

        if (w[i] != q[i + 1])

           return false;

        else

           continue;

   }

   return true;

}

Explanation:

Since it was mentioned that both arrays are of equal length, we use the length of the first array minus one as our condition in order check the last item. Then, we have to check first array even with second array odd so we increment by be i+=2 and not the popular i++. The continue statement ensures that as soon as only one case fails, the loop with stop and return true.

You might be interested in
Narrate an incident from the experience of a 14 year old girl which brings out the message: " Never leave till tomorrow what you
pogonyaev
Smth called google turbo record United in
7 0
2 years ago
2) [13 points] You’ve been hired by Banker Bisons to write a C++ console application that determines the number of months to rep
Paha777 [63]

Answer:

Check the explanation

Explanation:

CODE:

#include <iostream>

#include <iomanip>

using namespace std;

double getLoanAmount() { // functions as per asked in question

double loan;

while(true){ // while loop is used to re prompt

cout << "Enter the car loan amount ($2,500-7,500): ";

cin >> loan;

if (loan>=2500 && loan <= 7500){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: $"<< loan << " is an invalid loan amount." << endl;

}

}

return loan;

}

double getMonthlyPayment(){ // functions as per asked in question

double monthpay;

while(true){ // while loop is used to re prompt

cout << "Enter the monthly payment ($50-750): ";

cin >> monthpay;

if (monthpay>=50 && monthpay <= 750){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: $"<< monthpay << " is an invalid monthly payment." << endl;

}

}

return monthpay;

}

double getInterestRate(){ // functions as per asked in question

double rate;

while(true){ // while loop is used to re prompt

cout << "Enter the annual interest rate (1-6%): ";

cin >> rate;

if (rate>=1 && rate <= 6){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: "<< rate << "% is an invalid annual interest rate." << endl;

}

}

return rate;

}

int main() {

cout << setprecision(2) << fixed; // to print with 2 decimal places

int month = 0; // initializing month

// calling functions and storing the returned value

double balance= getLoanAmount();

double payment= getMonthlyPayment();

double rate= getInterestRate();

rate = rate /12 /100; // as per question

// printing as per required in question

cout << "Month Balance($) Payment($) Interest($) Principal($)"<< endl;

while(balance>0){ // while the balance is more than zero

month = month + 1; // counting Months

// calculations as per questions

double interest = balance * rate;

double principal = payment - interest;

balance = balance - principal;

// printing required info with proper spacing

cout <<" "<< month;

cout <<" "<< balance;

cout <<" "<< payment;

cout <<" "<< interest;

cout <<" "<< principal << endl;

}

cout << "Months to repay loan: " << month << endl; // displaying month

cout << "End of Banker Bisons";

Kindly check the output in the attached image below.

5 0
3 years ago
You may have come across websites that not only ask you for a username and password, but then ask you to answer pre-selected per
raketka [301]

Answer:

The questions are used to secure and identify you furthermore. Answering personal questions that only you can answer will deter someone from hacking into your account that easily.

Explanation:

5 0
2 years ago
Who says spirits of northern vale guide Me in Mobile legends
Yuliya22 [10]
What? i’m so confused lol, do you have a question?
4 0
2 years ago
Read 2 more answers
Users report that the database on the main server cannot be accessed. A database administrator verifies the issue and notices th
navik [9.2K]

Answer: (C) Ransomware

Explanation:

The ransomware is one of the type of malware software design which is used for blocking the user accessing unauthorized and also without paying money.

The most of the ransomware software encrypt the computer accessing and the files as they demand for the payment dues for again restoring the access.  

It also encrypt the user account and the information until the correct decrypt key are get entered into the system. So, according to the given situation, the ransomware attack are experienced in an organization.  

Therefore, Option (C) is correct.

4 0
3 years ago
Other questions:
  • In the U.S. highway numbering system, north-south routes have
    9·2 answers
  • Instead of typing out each co-worker's email address individually, you can use the Office Online People application to create a
    8·2 answers
  • Gunther is filling in his own input mask. He wants to format the Social Security numbers of his clients. The field must contain
    5·1 answer
  • Your manager asks you to calculate the sale price if the product is marked down 20 percent. You enter the original price in cell
    9·1 answer
  • Possible consequences for plagiarism, listed in CAVA's Academic Integrity Policy, may include:
    9·1 answer
  • Pls help brainliest
    12·1 answer
  • Your employer gives you a list of all chemicals in the entire building and the location of the SDS collection, and he asks you t
    15·2 answers
  • Which command could you use to change to the /usr directory using a relative pathname?
    8·1 answer
  • Summary about Interface Design in system analysis
    12·1 answer
  • What is an advantage of using a dynamic hard drive in a vm?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!