I'm using Visual Studio to make a grocery app for school that includes usernames and passwords. I'm given all the code then it tells me to use search arrays to implement two functions. They should return true if the username and password is found in the arrays. But i can't seem to get the function and arrays right. Below is the code and I'm supposed to implement the array in the two empty functions at the bottom. Would really appreciate some help here, thanks

Module Main
Friend blnLoggedIn As Boolean
Dim arrUsernames() As String = {"Admin", "Clerk", "Manager"}
Dim arrPasswords() As String = {"password", "password2", "password3"}

Sub Login(username As String, password As String)
blnLoggedIn = False
If VerifyUsername(username) And VerifyPassword(password) Then
'Find index for username
Dim userIndex As Integer
For loopIndex = 0 To arrUsernames.Length - 1
If arrUsernames(loopIndex) = username Then
userIndex = loopIndex
Exit For
End If
Next
'Check for password match
If arrPasswords(userIndex) = password Then
blnLoggedIn = True
Else
MessageBox.Show("Incorrect password.")
End If
End If
End Sub
Function VerifyUsername(username As String) As Boolean

End Function
Function VerifyPassword(password As String) As Boolean

End Function
End Module

Answers

Answer 1

Answer:

VB:

   Public Function VerifyUsername(ByVal username As String) As Boolean

       For positionInUsernameArray As Integer = 0 To arrUsername.Length - 1

           If positionInUsernameArray = arrUsername.Length Then Exit For

           If username = arrUsername(positionInUsernameArray) Then

               Return True

           Else

               Continue For

           End If

       Next

       Return False

   End Function

   Public Function VerifyPassword(ByVal password As String) As Boolean

       For positionInUsernameArray As Integer = 0 To arrPassword.Length - 1

           If positionInUsernameArray = arrPassword.Length Then Exit For

           If password = arrPassword(positionInUsernameArray) Then

               Return True

           Else

               Continue For

           End If

       Next

       Return False

   End Function

C#:

sealed class Main

   {

       internal bool blnLoggedIn;

       string[] arrUsername = new string[] { "Admin", "Clerk", "Manager" };

       string[] arrPassword = new string[] { "password", "password2", "password3" };

       public void Login(string username, string passowrd)

       {

           blnLoggedIn = false;

           if (VerifyUsername(username) && VerifyPassword(passowrd))

           {

               // Find index for username

               int userIndex = 0;

               for (int loopIndex = 0; loopIndex <= arrUsername.Length - 1; loopIndex++)

               {

                   if (arrUsername[loopIndex] == username)

                   {

                       userIndex = Convert.ToInt32(loopIndex);

                       break;

                   }

                   else continue;

               }

               // Check for password match

               if (arrPassword[userIndex] == passowrd)

                   blnLoggedIn = true;

               else

                   MessageBox.Show("Incorrect password");

           }

       }

       public bool VerifyUsername(string username)

       {

           for (int positionInUsernameArray = 0; positionInUsernameArray <= arrUsername.Length - 1; positionInUsernameArray++)

           {

               if (positionInUsernameArray == arrUsername.Length)

                   break;

               if (username == arrUsername[positionInUsernameArray])

                   return true;

               else continue;

           }

           return false;

       }

       public bool VerifyPassword(string password)

       {

           for (int positionInUsernameArray = 0; positionInUsernameArray <= arrPassword.Length - 1; positionInUsernameArray++)

           {

               if (positionInUsernameArray == arrPassword.Length)

                   break;

               if (password == arrPassword[positionInUsernameArray])

                   return true;

               else continue;

           }

           return false;

       }

   }

Explanation:

First I created a for loop with a "positionInUsernameArray" and singed it a value of 0. Next I stated while positionInUsernameArraywas less than or equal to arrUsername.Length - 1, positionInUsernameArraywould increment.

Once the base for loop was in place I created two if statements. The first if statement determines if positionInUsernameArray is equal to arrUsername.Length, if so, the for loop breaks and the method returns false. The second if statement determines if the parameter is equal to the position in the arrUsername array, if so, the method would return true, otherwise the for loop will restart.

For the "VerifyPassword" method, I used the same method as "VerifyUsername" just I changed the variable names.

Hope this helped :) If it didn't please let me know what happened so I can fix the code.

Have a good day!


Related Questions

What are computer programs that make it easy to use and benefit from techniques and to faithfully follow the guidelines of the overall development methodology

Answers

Answer:

A Tool

Explanation:

Tools are computer programs that make it simple to use and benefit from techniques while adhering to the overall development methodology's guidelines. The correct option is A).

What are computer programs?

A computer-aided software development case tool is a piece of software that aids in the design and development of information systems. It can be used to document a database structure and provide invaluable assistance in maintaining design consistency.

A computer software application is one that is developed to assist a particular organizational function or process, such as payroll systems, market analysis, and inventory control.

The goal of introducing case tools is to reduce the time and cost of software development, while also improving the quality of the systems created.

Therefore, the correct option is A) Tools.

To learn more about computer programs, refer to the below link:

https://brainly.com/question/9963733

#SPJ2

The question is incomplete. Your most probably complete question is given below:

A) Tools

B) Techniques

C) Data flow

D) Methodologies

By Using the following schema, answer the following SQL queries and commands: Product(P_code.P_name, P_price, P_on_hand,vend_code) Vender(vend_code, vend_fname, vend_areacode, vend_phone) 1- find the venders names who sell products in TN-5 area and their names include "dan". 2- find the code, name and vender code of product that has price between 1500S and 2500S and the product that has price between 48005 and 5600S. 3- Find the name, and code of venders who had 5 microwaves that has price less than 3500S. 4- Find the phone numbers of venders who sell Televisions. 5- Delete the records of venders who their first name is 'smith'

Answers

Explanation:

answer me pls i need sol bbbd

Which one is the result of the ouWhen you move a file to the Recycle Bin, it will be immediately deleted from your computer.

A. True

B. Fals

Answers

Answer:

B => false

Explanation:

it just keep it on recycle bin => not being removed

False

Explaination :

The deleted file will stay in Recycle Bin for a short period of time before it's permanently deleted from your computer

mk chưa hiểu nên các bạn giúp mk vs

Answers

Answer:

my tab and state it all over my name to

What does the statement that follows do? double gallons[6] = { 12.75, 14.87 }; a. It assigns the two values in the initialization list to the first two elements but leaves the other elements with the values currently in memory. b. It assigns the two values in the initialization list to the first and second elements, third and fourth elements, and fifth and sixth elements. c. This statement is invalid. d. It assigns the two values in the initialization list to the first two elements and default values to the other elements.

Answers

Answer:

It assigns the two values in the initialization list to the first two elements and default values to the other elements.

Explanation:

Given

The array initialization

Required

Interpret the statement

double gallons[6] implies that the length/size of the array gallons is 6.

In other words, the array will hold 6 elements

{12.75, 14.87} implies that only the first two elements of the array are initialized ; the remain 4 elements will be set to default 0.

what is programming language?​

Answers

Answer:

A programming language is a formal language comprising a set of strings that produce various kinds of machine code output. Programming languages are one kind of computer language, and are used in computer programming to implement algorithms. Most programming languages consist of instructions for computers

Answer:

The artificial languages that are used to develop computer programs are called programming language . hope this help!

Which of the following are examples of third party software that banks use? (Select all that apply.)
A -compliance reporting
B -unencrypted Microsoft Suite
C -accounting software
D -customer relationship management

Answers

Answer:

c , it is a correct answer for the question

Analyzing the role of elements in audio editing and Video
+ analyzing the role of the visual element in Video + analyzing the role of text factor
+ analyzing the role of the audio factor
+ analyzing the role of the transfer scene
+ analysing the role of the audio visual effects

Answers

Answer:

Analyzing the role of elements in audio editing and Video

+ analyzing the role of the visual element in Video + analyzing the role of text factor

+ analyzing the role of the audio factor

+ analyzing the role of the transfer scene

+ analysing the role of the audio visual effect

Code Example 17-1 class PayCalculator { private: int wages; public: PayCalculator& calculate_wages(double hours, double wages) { this->wages = hours * wages; return *this; } double get_wages() { return wages; } }; (Refer to Code Example 17-1.) What coding technique is illustrated by the following code? PayCalculator calc; double pay = calc.calculate_wages(40, 20.5).get_wages(); a. self-referencing b. function chaining c. dereferencing d. class chaining

Answers

Answer:

The answer is "Option b".

Explanation:

Function chaining is shown by this code, as the functions are called one after the other with one statement. Whenever you want to call a series of methods through an object, that technique is beneficial. Just because of that, you may give the same effect with less code and have a single given value only at top of the leash of operations.

Write a program that randomly chooses among three different colors for displaying text on the screen. Use a loop to display 20 lines of text, each with a randomly chosen color. The probabilities for each color are to be as follows: white 30%, blue 10%, green 60%. Suggestion: Generate a random integer between 0 and 9. If the resulting integer falls in the range 0 to 2 (inclusive), choose white. If the integer equals to 3, choose blue. If the integer falls in the range 4 to 9 (inclusive), choose green. Test your program by running it ten times, each time observing whether the distribution of line colors appears to match the required probabilities.

Answers

INCLUDE Irvine32.inc

.data

msgIntro  byte "This is Your Name's fourth assembly extra credit program. Will randomly",0dh,0ah

        byte "choose between three different colors for displaying twenty lines of text,",0dh,0ah

        byte "each with a randomly chosen color. The color probabilities are as follows:",0dh,0ah

        byte "White=30%,Blue=10%,Green=60%.",0dh,0ah,0

msgOutput byte "Text printed with one of 3 randomly chosen colors",0

.code

main PROC

;

//Intro Message

      mov edx,OFFSET msgIntro  ;intro message into edx

      call WriteString         ;display msgIntro

      call Crlf                ;endl

      call WaitMsg             ;pause message

      call Clrscr              ;clear screen

      call Randomize           ;seed the random number generator

      mov edx, OFFSET msgOutput;line of text

      mov ecx, 20              ;counter (lines of text)

      L1:;//(Loop - Display Text 20 Times)

      call setRanColor         ;calls random color procedure

      call SetTextColor        ;calls the SetTextColor from library

      call WriteString         ;display line of text

      call Crlf                ;endl

      loop L1

exit

main ENDP

;--

setRanColor PROC

;

; Selects a color with the following probabilities:

; White = 30%, Blue = 10%, Green = 60%.

; Receives: nothing

; Returns: EAX = color chosen

;--

      mov eax, 10              ;range of random numbers (0-9)

      call RandomRange         ;EAX = Random Number

      .IF eax >= 4          ;if number is 4-9 (60%)

      mov eax, green           ;set text green

      .ELSEIF eax == 3         ;if number is 3 (10%)

      mov eax, blue            ;set text blue

      .ELSE                    ;number is 0-2 (30%)

      mov eax, white           ;set text white

      .ENDIF                   ;end statement

      ret

setRanColor ENDP

how did hitles rules in nazi germany exemplify totiltarian rule?

Answers

Answer:

hope this helps if not srry

write a program that keeps taking integers until the user enters in python

Answers

int main {

//variables

unsigned long num = 0;

std::string phrase = " Please enter your name for confirmation: " ;

std::string name;

//codes

std::cout << phrase;

std::cin>> name;

while ( serial.available() == 0 ) {

num++;

};

if ( serial.avaliable() > 0 ) {

std::cout << " Thank you for your confirmation ";

};

};

how do you get The special and extended ending in final fight 2 snes

Answers

Yes what that person above said!

5. Which events is used to code on any form load
a) Form Text b) Form Code c) Form Load d) Form Data

Answers

Answer:

I think b is correct answer

Write a program that asks the user to enter in a username and then examines that username to make sure it complies with the rules above. Here's a sample running of the program - note that you want to keep prompting the user until they supply you with a valid username:

Answers

user_in = input ("Please enter your username: " )

if user_in in "0123456789":

print ("Username cannot contain numbers")

elif user_in in "?":

print ("Username cannot continue special character")

else:

print (" Welcome to your ghetto, {0}! ".format(user_in))

when was first generation of computer invented? ​

Answers

Introduction: 1946-1959 is the period of first generation computer. J.P.Eckert and J.W. Mauchy invented the first successful electronic computer called ENIAC, ENIAC stands for “Electronic Numeric Integrated And Calculator”.

Algorithm
Read marks and print letter grade according to that.

Answers

Answer:

OKAYYYY

Explanation:

BIJJJJJJJSGJSKWOWJWNWHWHEHIWJAJWJHWHS SJSJBEJEJEJEJE SJEJBEBE

Write a program that accepts a list of integers and split them into negatives and non-negatives. The numbers in the stack should be rearranged so that all the negatives appear on the bottom of the stack and all the non-negatives appear on the top.

Answers

Answer:

The program is as follows:

n = int(input("List elements: "))

mylist = []; myList2 = []

for i in range(n):

   num = int(input(": "))

   mylist.append(num)

for i in mylist:

   if i >= 0:

       myList2.append(i)

for i in mylist:

   if i < 0:

       myList2.append(i)

print(myList2)

Explanation:

This gets the number of list elements from the user

n = int(input("List elements: "))

This initializes two lists; one of input and the other for output

mylist = []; myList2 = []

This is repeated for every input

for i in range(n):

Get input from the user

   num = int(input(": "))

Append input to list

   mylist.append(num)

This iterates through the input lists

for i in mylist:

If list element is non-negative

   if i >= 0:

Append element to the output list

       myList2.append(i)

This iterates through the input lists, again

for i in mylist:

If list element is negative

   if i < 0:

Append element to the output list

       myList2.append(i)

Print output list

print(myList2)

Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate line. For example, the input 16384 is displayed as 1 6 3 8 4 You may assume that the input has no more than five digits and is not negative.

Answers

Answer:

The program in Python is as follows:

num = int(input())

for i in str(num):

   print(int(i))

Explanation:

This gets input for the number

num = int(input())

This converts the number to string and iterates through each element of the string

for i in str(num):

This prints individual digits

   print(int(i))

Describe two types of storage devices?​

Answers

Answer:

Central Process Unit and Random Access Memory

What are some 5 constraints in using multimedia in teaching​

Answers

Answer:

Explanation:

Technological resources, both hardware and software

Technological skills, for both the students and teacher

Time required to plan, design, develop, and evaluate multimedia activities

Production of multimedia is more expensive than others because it is made up of more than one medium.

Production of multimedia requires an electronic device, which may be relatively expensive.

Multimedia requires electricity to run, which adds to the cost of its use

There are constraints in using multimedia in teaching​; The Technological resources, both hardware and software Also, Technological skills, for both the students and teacher

What is a characteristic of multimedia?

A Multimedia system has four characteristics and they are use to deliver the content as well as the functionality.

The Multimedia system should be be computer controlled. The interface is interactive for their presentation and lastly the information should be in digital.

There are constraints in using multimedia in teaching​;

The Technological resources, both hardware and software

Also, Technological skills, for both the students and teacher

Since Time required to plan, design, develop, and evaluate multimedia activities

The Production of multimedia is more expensive than others because it is made up of more than one medium.

The Production of multimedia requires an electronic device, which may be relatively expensive.

The Multimedia requires electricity to run, which adds to the cost of its use.

Learn more about multimedia here;

https://brainly.com/question/9774236

#SPJ2

Microsoft created Adobe Photoshop? TRUE FALSE​

Answers

Answer:

false the creator of adobe photoshop was microsoft adobe photoshop is a popular photo editing software which was developed by a company named as adobe inc.

Answer:

Photoshop is created by Adobe, and Adobe is an independent company started by Jhon Warnockand.

PartnerServer is a Windows Server 2012 server that holds the primary copy of the PartnerNet.org domain. The server is in a demilitarized zone (DMZ) and provides name resolution for the domain for Internet hosts.
i. True
ii. False

Answers

Answer:

i. True

Explanation:

A Domain Name System (DNS) can be defined as a naming database in which internet domain names (website URLs) are stored and translated into their respective internet protocol (IP) address.

This ultimately implies that, a DNS is used to connect uniform resource locator (URL) or web address with their internet protocol (IP) address.

Windows Server 2012 is a Microsoft Windows Server operating system and it was released to the general public on the 4th of September, 2012, as the sixth version of the Windows Server operating system and the Windows NT family.

PartnerServer is a Windows Server 2012 server that was designed and developed to hold the primary copy of the PartnerNet dot org domain.

Typically, the server is configured to reside in a demilitarized zone (DMZ) while providing name resolution for the domain of various Internet hosts.

In order to prevent a cyber attack on a private network, end users make use of a demilitarized zone (DMZ).

A demilitarized zone (DMZ) is a cyber security technique that interacts directly with external networks, so as to enable it protect a private network.

I wanna learn python but I don't know any websites that I can learn it online. Thanks for attention!

Answers

Answer:

https://www.codecademy.com/

Write a recursive function called DrawTriangle() that outputs lines of '*' to form a right side up isosceles triangle. Function DrawTriangle() has one parameter, an integer representing the base length of the triangle. Assume the base length is always odd and less than 20. Output 9 spaces before the first '*' on the first line for correct formatting.

Answers

Answer:

Code:-  

# function to print the pattern

def draw_triangle(n, num):

     

   # base case

   if (n == 0):

       return;

   print_space(n - 1);

   print_asterisk(num - n + 1);

   print("");

 

   # recursively calling pattern()

   pattern(n - 1, num);

   

# function to print spaces

def print_space(space):

     

   # base case

   if (space == 0):

       return;

   print(" ", end = "");

 

   # recursively calling print_space()

   print_space(space - 1);

 

# function to print asterisks

def print_asterisk(asterisk):

     

   # base case

   if(asterisk == 0):

       return;

   print("* ", end = "");

 

   # recursively calling asterisk()

   print_asterisk(asterisk - 1);

   

# Driver Code

n = 19;

draw_triangle(n, n);

Output:-  

# Driver Code n = 19;| draw_triangle(n, n);

Which of the given assertion methods will return true for the code given below? Student student1 = new Student(); Student student2 = new Student(); Student student3 = student1;
The Student class is as follows.
public class Student{
private String name;
}
a. assertEquals(student1, student2);
b. assertEquals(student1, student3);
c. assertSame(student 1, student3);
d. assertSame(student1, student2);

Answers

Answer:

The true statements are :

A. assertEquals(student1,student2)  

C. assertSame(student1,student3)

Explanation:

AssertEquals() asserts that the objects are equal, but assertSame() asserts that the passed two objects refer to the same object or not, if found same they return true, else return false.

Methods are collections of named code segments that are executed when evoked

The assertion method that will return true for the given code is: assertEquals(student1,student2)  

The code segment is given as:

Student student1 = new Student();

Student student2 = new Student();

Student student3 = student1;

In Java, the assertEquals() method returns true if two objects have equal values.

Assume student1 and student2 have equal values, the statement assertEquals(student1,student2) will return true

Read more about java methods at:

https://brainly.com/question/15969952

Queues can be represented using linear arrays and have the variable REAR that point to the position from where insertions can be done. Suppose the size of the array is 20, REAR=5. What is the value of the REAR after adding three elements to the queue?

Answers

Answer:

8

Explanation:

Queues can be implemented using linear arrays; such that when items are added or removed from the queue, the queue repositions its front and rear elements.

The value of the REAR after adding 3 elements is 5

Given that:

[tex]REAR = 5[/tex] --- the rear value

[tex]n = 20[/tex] --- size of array

[tex]Elements = 3[/tex] --- number of elements to be added

When 3 elements are added, the position of the REAR element will move 3 elements backward.

However, the value of the REAR element will remain unchanged because the new elements that are added will only change the positioning of the REAR element and not the value of the REAR element.

Read more about queues at:

https://brainly.com/question/13150995

What’s cloud-based LinkedIn automation?

Answers

Answer:

Cloud based LinkedIn automation includes tools and software that run through the cloud-system and are not detectable by LinkedIn. Cloud based LinkedIn automation tools are becoming the favorite among B2B marketers and sales professionals as they are giving the desired outcomes without any effort.

Phân tích vai trò của các yếu tố trong biên tập Audio và Video

Answers

Answer:

Answer to the following question is as follows;

Explanation:

A visual language may go a long way without even text or narrative. Introductory angles, action shots, and tracker shots may all be utilised to build a narrative, but you must be mindful of the storey being conveyed at all times. When it comes to video editing, it's often best to be as cautious as possible.

The analog computer deals directly with

Answers

continuously variable aspects of physical phenomena such as a electrical, mechanical etc.

The analog computer deals directly with measured values of continuous physical magnitude.

What is an Analog computer?

An analog computer may be defined as a type of computer that is significantly used to process analog data. These computers store data as a continuum of physical quantities and perform calculations using measurements.

It is completely different from digital computers, which use symbolic numbers to represent results. are great for situations that require data to be measured directly without conversion to numbers or codes. Analog computers, although readily available and used in scientific and industrial applications such as control systems and aircraft, have largely been superseded by digital computers due to the many complications involved.

Therefore, the analog computer deals directly with measured values of continuous physical magnitude.

To learn more about Analog computers, refer to the link:

https://brainly.com/question/18943642

#SPJ2

Your question seems incomplete. The most probable complete question is as follows:

The analog computer deals directly with:

number or codes.measured values of continuous physical magnitude.signals in the form of 0 or 1.signals in discrete values from 0 to 9
Other Questions
Sue read 12 more than twice as many pages is tom did last week if sue read 90 pages how many did tom read What is the credibility of the source?Historical sources? Explain create jobs in rural areas What does every race have in common? PLEASE HELPPPPPPPPP Can you please help me How many solutions will each system of linear equation have? 100 points please read this ASAP and helpread these comments :D Operating Leverage Beck Inc. and Bryant Inc. have the following operating data: Beck Inc. Bryant Inc. Sales $1,250,000 $2,000,000 Variable costs (750,000) (1,250,000) Contribution margin $500,000 $750,000 Fixed costs (400,000) (450,000) Operating income $100,000 $300,000 a. Compute the operating leverage for Beck Inc. and Bryant Inc. If required, round to one decimal place. Beck Inc. fill in the blank 1 Bryant Inc. fill in the blank 2 b. How much would operating income increase for each company if the sales of each increased by 20%? Dollars Percentage Beck Inc. $fill in the blank 3 fill in the blank 4 % Bryant Inc. $fill in the blank 5 fill in the blank 6 % c. The difference in the of operating income is due to the gi s bn l i trng ca khoa tham gia gii sinh vin khi nghip bn s p dng phong cach lnh o no? ti sao li chn phong cch why is volume calculated in units cubed? Please help asap for 100 pointsss~!!!!! Plz help guys thank u. explain the structure of molar Which of the following is true about "natural" steroids?A) They are illegal to use in most sports B) They are safe substitutes for anabolicsC)They do not work better than high protein foods D)They will bulk up muscles just like anabolics What is the value of c in the interval (5,8) guaranteed by Rolle's Theorem for the function g(x)=7x3+91x2280x9? Note that g(5)=g(8)=9. (Do not include "c=" in your answer.) AYUDA EL QUE LA RESPONDA ESTA PREGUNTA O TAREA LE DOY MAS PUNTOS LO MAS PRONTO POSIBLEsignificado tieneesta frase de Bob Marleycrea una nueva sobre el sin sentidodel racismo mientras el colorde la piel de lasPERSONAS seamas inportanteque la de SUS OJOS,LAS GERRASSEGUIRANaxistiendo.. What is the product?(x^4)3x^3-2)(4x^2 +5x)? Resuelve el siguiente problema un buzo en una laguna decendio 8m en una hora.Si cada hora bojo la misma cantidad de metros, cuantos metros bojo en 4 horas On a pie chart, a category representing 20% of the whole should correspond to a central angle of 20. As a result of the Missouri Compromise, Maine entered the Union as a slave state and Missouri entered as a free state.Maine entered the Union as a free state and Missouri entered as a slave state. Both Maine and Missouri entered the Union as slave states. Both Maine and Missouri entered the Union as free states. An initially motionless test car is accelerated uniformly to 105 km/h in 8.43 s before striking a simulated deer. The car is in contact with the faux fawn for 0.635 s, after which the car is measured to be traveling at 60.0 km/h. What is the magnitude of the acceleration of the car before the collision?acceleration before collision:3.45m/s2 What is the magnitude of the average acceleration of the car during the collision?average acceleration during collision:19.68m/s2 What is the magnitude of the average acceleration of the car during the entire test, from when the car first begins moving until the collision is over?