PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. Along with the proper indenting it makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. This will not automatically indent your code. That part is up to you. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
keskiverto once wrote: |
---|
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions. We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. |
1. Print the entire list. This menu item is selected by typing 1 and it should simply print the contents of the file in suitable format on the screen. (Fields (columns) to display in output are: lastname initial, FNPF#1, age, Gross_Income and Resident). 2. Print list sorted by Gross Income This menu item is selected by typing 2. Program then prints the list in ascending order of Gross Income. (Fields (columns) to display in output are: FNPF# and Gross_Income) [An algorithm to sort an array is given at the end of this project description]2 3. Print list of employees which match a given lastname initial The user selects this option by typing 3. Then the user is asked to enter the search initial. If there are employees who have that initial, program prints their record, otherwise a if no students have last names matching the search initial a “no matching record found” message is displayed. (Fields (columns) to display in output are: lastname and FNPF#)CS111, USP – Assignment 2 S1/2021 Page 5 of 10 4.Calculate and Print in a file called IncomeTax.txt, the tax and the net income corresponding to the provided Gross Income. The user selects this option by typing 4. The program then calculates and prints to a file IncomeTax.txt, the tax corresponding to the provided Gross Income and the Net Income. The format of the resultant file is shown below (the columns are separated by tabs)3 [NB. The formula/criteria for calculating the Tax corresponding to the provided Gross Income is given in Table 1 and the Net Income = Gross Income – Tax] 5. Exit program User selects this option by typing 5. This is when program should end. [Note: After each command is processed (except menu 5) program must display the menu options again 1. FNPF# is? Give a description and an example. 2. Provide algorithm, so there is code offered that you can not use. 3. Give some idea of the table used. If there is an input file provide a sample or the whole file. Provide the operating system that you are using and the IDE/compiler and version numbers if you know them. If you know the C++ standard that the IDE/compiler is set up to use mention that. It also helps to have an idea of what you have studied and what you are expected to use. This way you are less likely to get code that you can not use. |
Plan your dive and dive your plan. |
|
|
|
|
if(inFile.is_open())
. To be blunt it is kind of tacky to run the whole "main" function on an if/else statement. And with the revised if statement you do not need this. The other problem is that your file stream may be open until you close it, but may still not be usable. I would look at it as if you need this if statement then you did something wrong.while (inFile >> ln_Initial[i])
or you could put the entire read line in the condition that way if any part fails the entire condition fails.ln_Initial
is fine, but in some fonts the lower case (L) can be mistaken for the number (1). The same occurs with the letter O and the number (0)zero. in some fonts it may be hard to tell the difference.
Andy , no i havent studies vectors please provide me any notes that i should study
|
|
|
|
while(!inFile.eof())
this is the output I get:INCOME RECORDS OF EMPLOYEES IN A FIRM ------------------------------------- Choose from the following Options: 1) To Display the entire list 2) To Display the list in the Ascending order of Grosss Income OPTION: 1 F 12345 2440000 Y // <--- needs a space or 2 betwenn the 24 and 40000. B 12361 1920000 Y H 34763 47100000 N H 11224 5035000 Y R 54129 3575000 N B 10717 26280000 Y ╠ -858993460 -858993460-858993460 ╠ |
while(!inFile.eof())
. As you can see the while condition is not working the way that you are thinking or want.
|
|
|
|
|
|
|
|
INCOME RECORDS OF EMPLOYEES IN A FIRM ------------------------------------- Choose from the following Options: 1) To Display the entire list 2) To Display the list in the Ascending order of Gross Income 0) Quit OPTION: 1 Initial FNPF# Age Gross Resident F 12345 24 40000 Y B 12361 19 20000 Y H 34763 47 100000 N H 11224 50 35000 Y R 54129 35 75000 N B 10717 26 280000 Y Choose from the following Options: 1) To Display the entire list 2) To Display the list in the Ascending order of Gross Income 0) Quit OPTION: 2 Initial FNPF# Age Gross Resident B 12361 19 20000 Y H 11224 50 35000 Y F 12345 24 40000 Y R 54129 35 75000 N H 34763 47 100000 N B 10717 26 280000 Y Choose from the following Options: 1) To Display the entire list 2) To Display the list in the Ascending order of Gross Income 0) Quit OPTION: 0 |