1. the user will be ask to enter its code
2. will output the searched code and then
3. the user will be ask to enter how many pcs he/she will buy.the formula should be
pcs=pcs-users_input if the user selected the code 001 and enters only 1pc it should be updated to only 3 pcs left in the file.
And so on ... it could be up to any alphabet. The number of As and Bs and Cs and Ds in first column depends on the number of unique alphabets used in the first column. For example the unique alphabets used in this case are 2 (A,C) hence each alphabet appears in the first column of consecutive 2 rows.
Which means
Code: A:A,B,C,D B:B,C,D,E C:C,D,E,F D:D, ,F,G (E is missing)
Actual Data A,1 A,2 A,3 A,4 C,18 C,33
Final Solution: Add each integer value to its previous value and store the resulting value.
We were given a task to use lists and iterators. We were supposed to make them from scratch. I'm done with that. The problems that I'm having are as following:
1. I'm not able to access the list made of Course datatype which is present in each Student instance. Does this mean I need to make an iterator for that course list inside the student class?
2. Similarly since I don't have direct access to The course list so I added the course into the Student list through the student objects not through the iterator. How can I do it through the iterator?
3. Printing of a particular student and his courses is not happening as my iterator made for student only prints out the students, not the courses present in their courselist. How to do that?
Here's the code
#include <iostream> #include <string> using namespace std; const int ILLEGAL_SIZE = 1; const int OUT_OF_MEMORY = 2; const int NO_SPACE = 3; const int ILLEGAL_INDEX = 4;
I have the following code and I am trying to do simple math calculations to the data. I need to take the car price (y) minus down payment (z) and then divide that quantity by 12 times "yearsx" That answer is then assigned to x. The problem is that x will not print the correctly!I also noticed that if I increase the "count" to amnything higher than the number on lines in the file, I get the correct value for x but only on the last set of the struct..my file reads as follows:
last_name first_name car_price down_payment years johnson bill 10,000 2,000 3
When I printf the struct to the screen, i need to do the following:
x = (10,000 - 2,000)/(12*years);
but this is the math part that wont work. I have checked and doubled checked number types and I cant get it right.
Implementing and manipulating a Polynomial ADT using a linked list.
So far I have:
poly_ADT.h Code: typedef struct nodeT{ int coef; int powr; struct nodeT *next; } node;
[Code]...
I need to create a function that creates the polynomial using input first.
poly *poly_create (num,...) ;return a new polynomial with num terms terms are listed in order of lowest ordered-term to highest. i.e., to initialize poly 15x^6 + -9x^4 + 3x^2 call poly_create(3, 3,2, -9,4, 15,6 );
Once I do that I need to implement various functions that can manipulate the polynomial itself but I'm having trouble just with creating the polynomial itself, how to do that using a linked list and nodes?
where num1 and num2 are arbitrary numbers. and Terrain is the class of objects I'm trying to store.
I want to be able to use push_back on both the main vector and the vectors within the mapArray vector but I'm unsure of how to target the inner vectors with push_back. How to dynamically store a 2D array of objects.
Why do most C examples pass a double pointer when manipulating linkedlists? Why can not we just pass a single pointer to the struct?I think using an external reference accessor for a linked list would be a more appropriate solution, yes or no?
Ben has been administering a MBTI personality test. Now he has all the responses, but the task of scoring and compiling results seems daunting. The personality test* is a series of 70 questions for which the available responses are ‘A’ and ‘B’. Based upon the answers to the 70 questions, a personality profile is determined, categorizing the degree to which the responses place the person on four scales:
Extrovert vs. Introvert (E/I) Sensation vs. iNtuition (S/N) Thinking vs. Feeling (T/F) Judging vs. Perceiving (J/P).
Each of the 70 questions relates to one of the four scales, with an ‘A’ response indicating the first of the corresponding pair (E, S, T, or J) and a ‘B’ indicating the second (I, N, F, or P). For instance, an ‘A’ response on the question: At a party do you:
A. Interact with many, including strangers B. Interact with a few, known to you indicates an Extrovert rather than an Introvert; just the opposite for a ‘B’.
For this test, each question is designed to influence one of the four scales as follows: questions 1, 8, 15, 22, 29 … are used to determine E/I, questions 2, 9, 16, 23, 30 … and 3, 10, 17, 24, 31 … to determine S/N, questions 4, 11, 18, 25, 32 … and 5, 12, 19, 26, 33 … to determine T/F, and questions 6, 13, 20, 27, 34 … and 7, 14, 21, 28, 35 … to determine J/P. Notice these come in sequences of “every 7th” question.
The goal of the test is to determine which end of each of the four scales a person leans, and to thus classify him/her based on those leanings (e.g., as ENFJ, INTJ, etc.). Since Ben would also like an indication of how strongly the test taker fell into each of the four, the program should print the percentage of ‘A’ responses for that scale.
Input for this program should come from a file responses.txt. The first line of the file will contain a single integer, n, indicating the number of test results to follow. Each of the following n lines will contain the first name of the test taker, a single blank, his/her last name, a single blank, then the 70 responses he/she gave on the test. Although the test instructions indicate that the results are most valid when all questions are answered, sometimes respondents leave questions blank. In that case, a dash appears at the corresponding place in the list of responses.
Output for the program should be written to the file types.txt. It should include a well-formatted report listing, for each test taker, his/her name, the percentage of ‘A’ responses in each scale, and the resulting personality type. A tie within a scale should result in a dash (‘-‘) for that part of the personality type.
I am trying to stream data to a file, and then return to the file to add further data. When I add data the second time, I then want to update the value of the second byte in the whole file. I can't seem to do this!
Here is my sample code:
Code: int a = 1; int b = 2; int c = 3; int d = 4; int e = 5; int f = 6; int g = 7; int x; fstream out1("file.dat", ios::out | ios::binary | ios::trunc);
[code]....
The output I get is "1, 2, 3, 4, 5, 6", but I want to be getting "1, 7, 3, 4, 5, 6", because in "out2", I seekp to the second integar entry, and change it to "7".
I have also tried using ios::ate in the constructor for "out2", but this gives me the out put "4, 7, 6, 6, 6, 6", which is suggesting that when I create my fstream object "in", any seekg commands are relative to the beginning of the "out2" stream, rather than the "out1" stream.
#include <iostream> #include <fstream> using namespace std; int main() { int r = 0; int c = 0; int num[17][15] = { 0 }; [Code] ...
// Here is my code for displaying the data from the text file into a 2d array and height next to it, but I am not able to diaplay the height from 60 to 76 next to the row of the 2d array, as shown in the table below. This is my program:
Recently the health authorities have listed a new way to calculate the body mass index (BMI) of an individual. Values of 20 – 24 are classified as normal, 25-29 as overweight, and 30-34 as heavy.
The table below is a portion of a typical BMI table.
Since the calculation I performed gives me -71.77 Volts, I need to match this value to the time that this occurs closest to using my program, and output the time that this occurs at.
Here is my program so far: int main() { std::ifstream inFile; inFile.open("AP.txt"); ofstream results_file ("maxvaluewithinput.txt"); float TimeAtdVMax = 0; float VoltsAtdVmax = 0;
[Code]...
If you're curious, this program isn't for homework. It's part of the independent learning on C++ I'm doing for a Master's Thesis; the program will eventually model the APD90 of a ventricular action potential.
I am very very new to C++. A bit of background. I have been writing in excel vba for large number crunching, and the code is now taking quite a while to run. A friend of mine suggested i start writing in C++, so i read up on it. And downloaded Code:Blocks.
My VBA Code is:
Sub arrayss() Dim NameArray As Variant Dim datarray As Byte Dim DirectionArray As Variant Dim WinArr As Variant
[Code] .....
Ultimately i would like to recode this to C++, but my first and probably silly question is how do i get the data from Excel to use in C++. I was thinking either to put the data in 3 csv files and convert into three Arrays in C++. Or maybe create a library of the data in C++. Ultimately it is speed i am looking for, so before i start recoding i wanted to start with the best way.
The data is like this in excel: (don't know how to create a table)
So the headers would be in one array, the 15's, 30's etc would be in another array and the 1's and 0's and Empty ( i need it to record an empty cell) would be in another array...
I have written a C++ program I have multiple of CSV file used as input, which I open one at a time and close it after extracting data to a output file which is the only file.
I run getline(inFile,line); outFile << line << endl;
I run this code, and only part of it is goes to the output file I got, also have spacing randomly to specific file and inconsistent
But when I slower the code, like system("Pause") in the loop, I can get extract what I want perfectly....
Is my program running to fast, why getline would be skipping part of what things I want?
I have a program I have to do that counts the number of words in a text file. I have tried the code on 2 computers now since my programming teacher told me the code was fine. Here is my code:
#include <iostream> #include <string> #include <fstream> using namespace std; int main() { ifstream infile; infile.open("tj.text" , ios::in);
I am reading a file then printing the data onto the other file. It is working, however when I check to see if each variable is being properly set after reading the file a issue arises.
Example of the file being read
Code: Vehicle PV50CAN passed camera 1 at 05:33:26. Vehicle W867BRO passed camera 1 at 05:33:29. Vehicle KQ63ARU passed camera 1 at 05:33:38. Vehicle K954ITQ passed camera 1 at 05:33:40. Vehicle V220MXB passed camera 1 at 05:33:42.
I need to perform operations on data from .data file i am able to load the file but how to use the data and perform operations on it. The file had roughly around 200 entries.
Following is the program I wrote it basically takes 9 inputs and then save them into binary file. then print out the data stored in binary data and find inverse of it then print the inverse out. but its stuck in a loop somewhere.
Code: #include <stdio.h> int main() { int a[3][3],i,j; float determinant=0; int x; FILE *fp = fopen ("file.bin", "wb");