Ok, I realize that I shouldn't be asking this, and probably will not get any responses, but it is worth a shot!
I have my first C++ program due in 4 hours and I need help, a lot of help!!!
I am supposed to write a program to read a series of integers using end-of-file loops, echo printing, and symbolic constants.
Unfortunately, my professor has not taught a lot thus far in class and I have not taught myself as I should in these situations. Does anybody have an example program (similar to mine) that they can share?? or any help on how to echo print, and/or convert ASCII to numbers???
Any help is appreciated, thank you...
OK this is my code so far:
* Programmer Corwin L Smith
// CSC 201 - Program # 1 "Calculate Grade"
// Use end-of-file loops and nested loops and convert ASCII to numbers
# include <iostream>
# include <fstream>
using namespace std;
int main ()
{
ifstream data1d; // input file
ofstream out1d; // output file
const int NUMHOMEWORK = 7; //
const int NUMPROGRAMS = 4; //
const float MAXPROGRAMS = 400.0; //
const char ASCIICONVERT = 0X0F; //
data1d.open ("dat1d.txt"); // name of input file
if (! dat1d)
{
cout<< "failure to open dat1d.txt" << endl;
system ("pause");
return 1; // error condition
}
out1d.open ("out1d.txt"); // output file created by program
if (! out1d)
{
cout<< "failure to open out1d.txt";
system ("pause");
return 1; // error condition
}
system ("PAUSE");
return 0;
}
can anyone tell me if it lloks like I am doing this right ???
I am new to coding in C++, but I plan on learning it well and doing a lot with it .. so please bear with me a little while I learn the basics ...
is that where I should declare my symbolic constants??
and i should open my data file and create an output file before i do the end of file loops right ???
I'd help cls20433, except that I don't hardly use any of the C++ iostream stuff. I hope somebody soon helps you though because by my reckoning you only have an hour and a half left!
yea my professor just emailed me and told me he changed the due date to monday , :), thank god!!
i hate to be so behind and ask this kind of thing of ppl, because I have every intention of learning the language and doing well in this class,
just been a rough start to the semester with moving, hurricane, no power, driving an hour each way for one class, yada, yada ... lol
thankx though,
and i def. still need help if anybody is willing!!
Will it be useful if i tell you in ASCII "0" is 0x30, "1" is 0x31, ... "9" is 0x39 ...?
Edit: I could have been helping you if you used stdio.h and not iostream.
...right after my includes at top. Also, do you know how to use code tags? A lot of folks won't even look at code if it isn't decently formatted with code tags. Maybe you could repost?
I'm like EssGeEich above. I don't use iostream. But you'll have to learn it unfortunately.
Here is a little program to get you started. You'll have to figure out how to convert it to use iostream. I made a text file with 8 grades in it like so named "Grades.txt"...
Ok, sorry for taking so long to reply .. had a physics test and some other shit I had to take care of before delving back into the C++ work I have to do ... and yes that is helpful, but,
what do you mean by code-tag exactly???
I have the general structure of my loop down, just having trouble formatting the inside loops 0- which are suppose to control the flex. number of homeworks, and i have to make a statement to drop the lowest test grade too...
that is helpful though, I am going to go through your ex. and try and apply it to my program..
give me a couple hours and i will repost the latest on what I have so far ..
thankx again
Its hard to show how to use code tags as they are special formatting symbols. Here is from a recent webJose post where he somehow managed to get the idea across...
Properly formatted code makes it easy to understand what the code is doing in terms of such constructs as if statements, loops, etc. I'm pretty anal about it myself. I think a lot of coders are. I just want to see my code a certain way. But however you format it so that others can see levels of if/loop logic, any other coder can deal with it.