Visual C++ :: Program To Output A Line For A Specific Age Group - CPP File
Feb 13, 2013
I am suppose to make a program that will output a line for a specific age group,but everytime I execute the exe file it gives me the desired line and also the last line included everytime.Where did I go wrong with it including the last line everytime?
#include <iostream>
using namespace std;
int main() {
double age;
cout<<"Enter your age:";
cin>>age;
if (0<age && age <6)
I am working on a project for school that has us read in a text file that contains 8 lines of SSN and grades. I am not sure how to go about reading in the lines and differentiate between the SSN and grades in the calculations.
How can I create in my C++ program so a user can paste a text and then choose a character on specific line and place?. The above thing isn't that important. I just want to place a character on a specific line and place.
I mean something like this:
Enter a character:
You choosed " / "
On which line do want the character?
You choosed "Line 1 and 2"
Where do you want the the to appear on the line? (left or right)
I am working on an assignment to enter a number and print all the prime factors of that number. I have that working, but the assignment demands the output be formatted in a strange way which I can't figure out. For example, in my current program entering 10 gets me 25, which is actually 2 and 5. But it should get me: ( 2 * 5 ) but I can't figure out how to do this. On the chance you need it, my code is below:
Code:
#include <iostream> using namespace std; int main( ) { cout << "Number: ";
I am currently working on a small project, which is an ATM simulator but, lately, I've been stuck in a part where I have to overwrite a specific line in a .dat file to update the account's checking and savings balance, once the transaction has been done. I have to use StreamReader and StreamWriter to complete the task and I have also being told to try Collections... which I'm not sure as to why.
Here's my code so far:
private void btnOKd_Click(object sender, EventArgs e) { int transaction = 0; atmTIMER.Elapsed += new ElapsedEventHandler(timerRESTART); FileStream fileTRANSACTIONS = new FileStream("C:\Users\Voyage\Desktop\ATMSim\ATMsim\Transactions.dat", FileMode.Open);
I was given an assignment to create a simple program for traffic control. How should i output data at a specific time, for e.g a driver approaches an intersection, the yellow light will flash indicating that he needs to slow down and then the red light to stop before taking a route. is there any function i can use to output red light a few seconds after yellow light.
I am trying to print a specific line from a textfile
e.g I have a text file called info.txt and inside it contains the id,item name, price, quantity
Code: 1,shirt,100,10 2,pants,50,9 3,pen,20,8
I know how to find a specific word at the line in the file but how do I find and print out the specific line e.g(print out just the entire contents of line 2)?
Code: string temDescription; ofstream fout; int curLine = 0;
How to sum groups in C++? I have a class with 2 attributes (Group and Price). I need to find the group with the highest amount. I can find the max when it comes to finding a set of individual numbers but not when a group is required. For Ex:
Group A64 Group A48 Group A18 Group B49 Group B36 Group C64 Group C75 Group C87 Group C72
I have a problem with UDP Multicast. I managed to send UDP Multicast telegrams and receive them. But when I receive the telegram I need to find out to which multicast group address it was sent. So far I have:
When I read from.sin_addr.S_un.S_addr; then I get the original IP Adresse from the sender PC but I also would like to know to which group address it was sent. Is there a way to get this infoamtion?
I am reading in some large files to process. The files need to be parsed into multi-line sub units for processing (by a different physical process). My current setup is crude and parses the entire file into memory before beginning to process the sub units. This is fine as long as the file fits, so I get into trouble > 2GB or so when my machine flat runs out of memory. The simple thing to do is to only read in some of the file, process what was read in, and then read in more. I more or less know how to stop reading at some point in the file, but I'm not sure how to resume from that point later when I need more data. Is there a way to count lines and then getline() starting from a specific point in the file? From reading the getline() doc, it doesn't look like there is.
This is my current function,
Code: void ParseFile(char *path, char type) { // open input file ifstream input_file(path); if( !input_file.good() ) { cerr << "Failed to open " << path << endl; exit(ERRCODE_ERROR); } int pos = 1;
[Code] ....
I need to remove the code to open the file from this function and open it elsewhere. I would like to call this every time I run out of data, if( tasks.empty() ), and get more data from the input file, but I don't know how to resume reading the input file from where I left off.
If this is not possible, I guess I would have to place a function call in while( input_file.good() ) to call out and process the data I have. When the current tasks list is finished, the list could be cleared and control returned into the while loop to continue reading input and start re-populating the list.
Write a program that reads a group of chars till $. Then, compute # of vowels, # of digits, # of word and # of special chars. Your program should display all required results.
I need to edit ,update and display a group of 40 parameters on screen. (10 parameters per page and use of Arrow Key pad or touch screen clicks to modify value)....
For that I will need .. Parameter No . , String Name , Point Screen Cord , double value , next element no. etc I have my old code with structure and array of structure written in C. I have translated it on C++/MFC .
Write a well-commented C++ program that reformats and outputs the date. Prompt the user to input the date in the format dd/mm/yyyy and outputs it in this format month, dd, yyyy. For example, 07/06/2012 is displayed as June 07, 2012. You are provided with the file months.txt containing the months and their corresponding numbers, for example 01January 02February etc. Use getline(monthsFile,monthString) to read in a string from the file, and use the monthString.find() function to search for the number and extract the corresponding month.
-confused by the way she told me to use getline(monthsFile,monthString) => if I just do it like this I only get the first line from the txt file (01January) -if I try putting all the months on one line in the txt file (which i'm not even sure i'm allowed to do), I'm not sure what to do for the length of my substring output. if I make it long enough to fit longer months like September, someone entering may gets both may and june in the output -if I input all the months into separate variables, I'm not sure how to make it only output the month entered by the user
I have been working on a program to scanfile and whenever it encounters what the user wanted it prints it, and it is all right less the first line of the file that the program jumps,
The program is showing zero in output section ....
Code: #include <iostream> #include <cstdio> #include <fstream> #include <string> #include <iomanip> using namespace std; const int SZ = 55;
[Code] ....
The output:
Code: First Last Employee Hours Rate Regular Overtime Gross Name Name Number Worked of Pay Pay Pay Pay ============================================================== Jane Adams A1234 40.00 10.00 0.00 0.00 0.00 Mary Lincoln L8765 50.00 10.00 0.00 0.00 0.00 Martha Washington W7654 25.50 10.85 0.00 0.00 0.00 John Adams A9876 52.00 15.75 0.00 0.00 0.00 George Washington W1235 45.00 25.00 0.00 0.00 0.00 Abraham Lincoln L9087 40.25 55.00 0.00 0.00 0.00 William Tell T9876 30.00 9.75 0.00 0.00 0.00
I've spent some time trying to performance test various methods of loading / accessing a file, either into memory or through a memory mapped file, but I am having some trouble.
FILE * pFile; std::ifstream ifs; MapViewOfFile
I'm have trouble because Windows appears to cache the file, so I am getting very mixed results. Sometimes a huge file (100's MB's) will load quickly, other times almost instantly.
How to stop Windows from doing whatever it's doing, so I can see the real time taken to load/access a file from disk?
If let's say I key in 2, it will search for the id=2 and delete the whole line and the id of banana which is orignially 3, will become 2 and orange which is orignally 4 will become 3 etc.
I researched on how it can be done and most suggested to put inside a vector and fout the line.
I know how to put the values in the vector but how should I go about searching for the id and if the id is found it will delete that line inside the file.
Code: ofstream fout; ifstream readFile("fruit.txt"); while (getline(readFile, line)) {
One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:
John K. 99, 87, 57, 89, 90, 95 Amanda B. Jones 100, 88, 76, 99, 86, 92 etc..
The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.
Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:
I wrote this code to search words in the file and display if the program found the word or not. when i write the words in the file on the same line (without the endl) like this :
w_toFile << "gilbert"; w_toFile << "lara"; w_toFile << "rana"; i can search any word.
but when i write them with the endl, the program can find only the first word. what can i do to make the program find any word even if they are each on a line?
here is the full code:
#include <iostream> #include <windows.h> #include <fstream> #include <string> using namespace std; int main (void) { string wordsearch;
I must create a program (a simple main.cpp in console interface) which deletes two spaces for every newline in a file. If a line has no space, it goes straight to the next line to the end of the file. After the program is to resave the file contents into a new file that has the same name as the old, but change the extension to. Modif
The problem is I can not do that ... Do you have a sample code that does this?
Actually the below program is for Dispersal Algorithm called Rabin-IDA; this algorithm divided the data into N pieces and then recombine it from M pieces (such that M<N).
Thus, the below program needs command line arguments,which entering by Project properties/Debugging. this argument is file name, where the program performing spitted the file into N files, and then recombine it from M divided files, and put it on another file which should also passing its name as argument .
Now my question is, How can i make this program enter the file name by keyboard??(i mean enter the files name by user from screen not as command line arguments) ... In another word, How I can exchange ?
Code: argc == 3 and Code: argc == 2
To enter file name ? i mean what i should do to in
Code: rabin.split(argv[1])
To pass my file name by use keyboard not Project properties/Debugging?)
the below code is just the main function of program, and the whole of it in this link [URL] .... Information Dispersal Algorithms Rabin-IDA.
#include <stdio.h> /* function that will identify if line is empty or not */ is_empty(char *buffer) { while(isspace(*buffer)) buffer++; if(*buffer==0x00) return 1;