logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

You must write the functions listed earlier, you cannot modify the function prototypes you may add additional functions

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Storm Trooper Recruitment (using parallel arrays)

You will need to declare the following arrays:

  • string names[SIZE] - stores the names of all the candidates

bool targets[SIZE][TRGTS] - a 2D array that stores each candidates successful/failed target at- tempts,  i.e.  targets[0][0],  targets[0][1],  targets[0][2],...,targets[0][TRGTS  -  1]   denotes which targets the first candidate hit/missed, TRGTS will be a constant with the value of 10

double targetWeights[TRGTS] - stores the weights for each target to be used to compute each can- didates overall scores

  • double scores[SIZE] - stores the score of each candidate (score is computed using the

Where SIZE is a constant that contains 20 (you can assume that the file will not have more than 20 entries).

You will also need to implement the following functions

int  readData(string[],  bool[][TRGTS],  double[]) - reads in the stormtroopers from a data file, the function prompts for an input file name and re-prompts if file not found, then reads each line and stores the data into the correct array at the appropriate location, you will maintain a counter that counts the number of lines in the storm trooper file, the file format is

NAME T1 T2 T3 T4 T5 T6 T7 T8 T9 T10

Where each Ti will be a string that contain ”Hit” or ”Miss” (might need to format), and so you will store true for hit and false for miss into the correct position of the bool matrix.

Additionally, this function will prompt and read for a second input file, this second file contains TRGTS

amount of doubles to be stored in the double array (the third parameter)

After everything has been read from both files, return the counter that was used in the first file that denotes the amount of stormtroopers read.

double  computeScore(bool[][TRGTS],  double[],  int) - returns the score of the stormtrooper re- sults, takes in the targets array, the scores array, and the index of the stormtrooper whose score the function is trying to compute, to compute the score, you multiply the value at the same respective index from the double array with the bool array

void  outputStormTroopers(string[],  bool[][TRGTS],  double[],  int)  -  outputs  all  the  storm troopers in the list nicely formatted (refer to the sample output), function takes in the names of the stormtroopers, all the stormtroopers target data, overall score, and the amount of stormtroopers

void outputOneStormTrooper(string, bool[], double) - outputs a single storm trooper,  function  takes the name, target data, and score for a single storm trooper, notice that the bool array is a one dimensional array in this function scope

Contents of main

  1. Allocate your variables, constants, arrays, and any other variables you might use

  2. Call readData function and assign the value it returns into a variable, say amtStormTroopers

  3. Use a counter controlled loop that runs amtStormTroopers number of times, the body of the loop will call computeScore which will be assigned into the correct position of scores array

  4. Call outputStormTroopers function to output all the storm troopers

  5. Find the top 3 stormtroopers (the 3 storm troopers with the highest scores), YOU CANNOT SORT THE ARRAY FIRST, AND TO GET FULL CREDIT, YOU MUST HAVE  JUST  ONE LOOP, IF YOU NEED MORE THAN ONE LOOP YOU MIGHT HAVE A SLIGHT PENALTY, HOWEVER SORTING THE ARRAY WILL BE A MUCH LARGER PENALTY

  6. Once the top 3 stormtroopers are found, output them, use the outputOneStormTrooper function 3 times

 

Specifications

You must write the functions listed earlier, you cannot modify the function prototypes, you may add additional functions if needed however

Example Output

$ g ++ Assignment.cpp  - Wall - Wextra - pedantic$ ./ a. out

 

Please   enter   storm   trooper   results   file :   storm Trooper Invalid   file !

 

Please   enter   storm   trooper   results   file :   StarWars . txt Invalid   file !

 

Please   enter   storm   trooper   results   file :   Storm TrooperData . txt Stormtrooper   data   read   successfully

 

Enter   target   weights:   targets. txt Invalid file!

 

Enter   target   weights:   Storm TroopersAlwaysMiss . txt Invalid file!

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

543 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

820 Answers

Hire Me
expert
Husnain SaeedComputer science

778 Answers

Hire Me
expert
Atharva PatilComputer science

706 Answers

Hire Me

Get Free Quote!

407 Experts Online