Question

A. Discussion: At what point should you consider changing from individual variables to an array? Is...

A. Discussion: At what point should you consider changing from individual variables to an array? Is it reasonable to use an array when you only have two or three items to track? Why or why not? Consider the number of sets of those two or three items when making your decision.

B. Write the pseudocode to do the following:
1. Use arrays to store data for student names, ID number, and gender into an array (tip: parallel arrays)

2. Print the contents of each record using the array

3. Count the number of male and female students by using the array, and print the counts.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If we have less number(2 or 3) of items, we don't need to go for arrays, but if
we have more than that it is better to switch to arrays. It is because a lot of
repetition of statements we can avoid with for loops

We can have 3 arrays .one for names, one for IDs and one for gender such that
ith value in each array are linked with each other

string names[3]
string id[3]
char gen[3]

names[0] = "name1"
names[1] = "name2"
names[2] = "name3"

id[1] = "123"
id[2] = "345"
id[3] = "567"

gen[0] = 'F'
gen[1] = 'M'
gen[2] = 'F'

for (int i i<3 i++)
   print( names[i] , id[i], gen[i])

countMale = 0
countFemale = 0
for (int i i<3 i++)
    if (gen[i] == 'F')
        countFemale++
    else
       countMale++

print(countMale)
priny(countFemale)

Add a comment
Know the answer?
Add Answer to:
A. Discussion: At what point should you consider changing from individual variables to an array? Is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. All functions should be written AFTER the main procedure. 2. A function prototype should be...

    1. All functions should be written AFTER the main procedure. 2. A function prototype should be written for each function and placed BEFORE the main procedure. 3. Each function should have a comment explaining what it does. 4. Each function parameter should have a comment explaining the parameter. 5. Prompt for the number of elements of the list. 6. Allocate an array whose size equals the number of elements specified by the user. 7. Read into the array the elements...

  • Program Overview This brief exercise is designed for you to consider how reference variables behave when...

    Program Overview This brief exercise is designed for you to consider how reference variables behave when you are passing them as arguments by-value. Instructions Name your class References.java. 1. Implement the following methods. 1.1 Method name: readStudentNames Purpose: This method accepts an array of strings as a parameter. It loops through the array and asks the user to input names. It populates the array of strings with the names. Parameters: an array of Strings, stringArray Return type: void In the...

  • Consider the following program that reads students’ test scores into an array and prints the contents of the array. You will add more functions to the program. The instructions are given below.

    Consider the following program that reads students’ test scores into an array and prints the contents of the array.   You will add more functions to the program.  The instructions are given below.              For each of the following exercises, write a function and make the appropriate function call in main.Comments are to be added in the program. 1.       Write a void function to find the average test score for each student and store in an array studentAvgs. void AverageScores( const int scores[][MAX_TESTS],                       int...

  • Using a list, create a game that allows a user 3 guesses. You should consider a...

    Using a list, create a game that allows a user 3 guesses. You should consider a list of 5 items (you can consider any list you want, e.g. a list of 5 different foods’ names).   You are to create a game that asks a user to make 3 guesses. Track the guesses and what the guess was. Provide a code that tracks all user guesses and counts those guesses. I want to create a simple code that allows the user to...

  • c++ can use if else, loop,function ,array,file i.o. Can not use swtich, global variables etc..   Please...

    c++ can use if else, loop,function ,array,file i.o. Can not use swtich, global variables etc..   Please do all parts. previously I post 3 time for part1 ,2 and 3 but I can't make it into one complete program code. I even try to post a questions ask and post the 3 parts of code for experts to put it together. But experts said it's not enough information. please help... Thank you ! Program Objectives: Allow students to create arrays Allow...

  • Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such...

    Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...

  • Using Java; Consider the following text file format. Ruminant Shaman 30 Elentriel Shaman 70 Aelkine Druid...

    Using Java; Consider the following text file format. Ruminant Shaman 30 Elentriel Shaman 70 Aelkine Druid 29 Barbatus Druid 70 Ukaimar Mage 47 Mariko Priest 33 Farmbuyer Priest 70 Valefar Warlock 42 Teslar Paladin 64 Nerdsbane Hunter 12 We wish to store information regarding several characters in a video game. Each character has a name, and a class, and a level. This information is repeated, 3 lines per character, for any number of characters. To simplify processing, the very first...

  • Please run the program and show the result with screenshots after. Thank you (Java Eclipse) Customer...

    Please run the program and show the result with screenshots after. Thank you (Java Eclipse) Customer Data: Area Codes Assume you work for a company that tracks customer information, including name, gender and phone numbers Your company has a file called customers.txt which contains the following information: Jiming Wu F 4082123458 James Brown M 8315678432 Leanna Perez F 4087654433 Xing Li M 8313214555 Stacey Cahill O 8312123333 Mohammed Abbas M 4083134444 Kumari Chakrabarti F 4086667777 Shakil Smith M 4082123333 Jung...

  • Objectives This is one of three major programming projects this semester. You should NOT collaborate on...

    Objectives This is one of three major programming projects this semester. You should NOT collaborate on this project. While you may ask for assistance in debugging, this project should be ENTIRELY your own work. Objectives include: . Use local variables. • Use arithmetic expressions. • Use Scanner to input values. • Use a class constant. • Use of nested branches. • Use for loxops. • Use of methods. • Use of arrays. Hand-in Requirements All projects and laboratories will be...

  • 6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you...

    6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you will practice working with arrays. Your program will read lines of text from the keyboard and use an array to track the number of times each letter occurs in the input text. You will use the contents of this array to generate a histogram (bar graph) indicating the relative frequencies of each letter entered. Test cases are available in this document. Remember, in addition...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT