logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

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

expert
Puneet GuptaStatistics
(/5)

618 Answers

Hire Me
expert
Pam SalvasLaw
(5/5)

689 Answers

Hire Me
expert
Vinay WahwaAccounting
(5/5)

500 Answers

Hire Me
expert
Woodrow BinionAccounting
(5/5)

784 Answers

Hire Me
C++ Programming

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!

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. 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

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme