I also tried something like
while(!inFile.eof)
...however, it says that the expression isn't valid. Pretty much what I wanted was for the program to stop/warn user in the event that there was an error in the infile...
I also tried something like
while(!inFile.eof)
...however, it says that the expression isn't valid. Pretty much what I wanted was for the program to stop/warn user in the event that there was an error in the infile...
string a ="apple";
string b ="banana";if (a > b )
{
//do stuff
}
so considering the fact, that each line in the inFile contains all leters of the alphabeth, at some point or the other....i'd have to use a lot of if-else statements? For example... if (x>y)...all the way down?
Good day guys:
The assignment is :
Write a program that will generate an unknown (between 93 & 139) count of random numbers whose values fall between 147 and 206. Calculate the average to 2 decimal places and the standard deviation (3 decimal places). On the monitor, display only the count of numbers, the average and the standard deviation. On the printer, display the same information after you have listed all the numbers in 5 columns in order from high to low and then skipped two spaces.
So far, this is what I've got. Thank you and have agood day. Any assistance is sincerely appreciated...
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
int main()
{
srand ( static_cast<unsigned int> ( time ( 0 ) ) );
int i;
int Low = 147;
int High = 206;
double numbers;//the actual numnbers
double avg;//average of group of numbers
double sdeva;// calcualtion parts of standard deviation
double sdevb;//actual square root for standard deviation
float count;//amout of numbers
int sum;//sum of the numbers
for (i=0; i<93 && i>139; i++)
{
numbers = rand()%(High-Low+1)+Low;
cout<<numbers<<endl;
}
{
if (i%5 ==0)
cout<<endl;
cout<<setw(10)<<numbers;
}
avg = numbers/count;
cout<<avg<<endl;
sdeva = ((sum * sum)/count) - ((sum * sum)/count);
sdevb = sqrt(sdeva);
cout<<sdevb;
return 0;
}
1. It's saying that 'numbers' is undeclared. I dont know why..isn't it declared ok?
2. How do I calcualte the sum, since it's going to change every …
Our professor simply wnet over the Bubble-sort, but he didn't specify what kinna sorts we were suppose to use..To be honest...I always thought Bubble sorts were for numbers...because you could always compare the values...but I have no clue about how to do it for letters. Thanks for you input.
Thanks much Salem....waht about the sorting of the names in normal alphabetical order?
The following is my "inFile":
UEAALEUE
RIXETOHI
BACOZOEI
DIUEAOAU
ZIKOFIMO
RESUZEAE
IIJEHUMO
EEQINOXO
TAOEKIBI
RUQICIGU
ZIWAREWE
HIDIFIFO
MOIACALA
MEJIEACO
UAPEUUQU
YISOZAZO
KENIDONA
EEVIYOHU
SEJEXEYA
OESEQUFU
NUJECAUE
RAKAWUME
NISIMAKE
MEPIBADO
TAUELAZI
IIEACINU
IITOGIIE
GIEIFEVU
NIOUQELU
IIVOFEHI
TOKUCORU
GUQOEOJE
HOBUUIXA
HOVEDAGO
JEROMAFA
TOLIOELU
QIGOIIAA
TEDEIUOA
COZOLELA
YOHUZUZA
QUNACAKO
POSAEIGA
JECAMOPE
VAKEKAPA
LEJEVINE
SONEBAEE
PEBINUGO
KONUNINE
BERIWUQO
WEXOIOVU
HIXUQIAE
IODOAUIE
HAKESUFA
ZIAIWAXA
DAGOGEBE
CUHIUAOO
DAVUAETU
COAUBAKU
IIMOJOLE
UIKIBUWU
SOEAOILA
VEGUKAXA
AUMATOUO
JOSUZIXI
COUOFUWI
ZILUAISU
SEZEIAVO
DEFISIZA
GOSUEUFO
ZEEAMAIA
POROEIDI
REGEJUPO
YUZUAOXU
AUZUXANI
SIZUZIEO
KIBEROWO
WEGIEAFA
PIPAAURI
UEJIEAZE
VIPIVICE
CASISUIO
FENOBOFU
GULEUEKO
NEUIGIJU
LICOXUDO
EUZAIAUA
LOUIOARU
DOKOWUUE
NEIIUEQO
FORUMOQU
KIWOOUXO
ZEMAFAIO
NAJEOAQI
YOIIBUFI
QOUOFIPE
EAOAPIMO
FAQALOLE
XEGIJELE
WOQEJAPO
XEOETUGE
BAEIUITA
DIHODETI
PUFIYARA
OEVINAYU
PIUOCOXI
YIBIZEOI
EADIGAFO
EUFENABU
HILAKOYE
DITAJARI
WEEIOOZA
TIAUSEAO
ZOVUROPA
PAQAWIRU
KUBOGESE
ZIZUAEOI
RAXUHAFU
The question is: Write a program that will read an unknown number of single names (of jumbled letters) into an array from a file named “listnames.txt”. There are no more than 120 names in the list. Sort the names in normal alphabetical order and then display them to the screen and print printer in 5 columns.
Any assistance is appreciated...The following (below) is what I have so far....but I want to make sure.....a couple things:
1st. The program keeps repeating the the groups of letters on the first line..why does it not read in the data from each line?
2nd. For right now..the program won't run....is it because of how I have my string 'names' declared? I pretty much want the program to read …
are you familiar with booting up the computer through the comand prompt at start-up?
In addition to viruses, your computer may be infected with spywares, Trojans, worms, adwares, viruses and other malwares. Also, I do recommend that you clean/restore your registry files…if these are corrupted, your PC will act crazy at times...Also try http://www.kaspersky.com/virusscanner , let is scan your computer. Do the following to post a hi-jack log which we'll address for you, you must first download the software from:http://www.download.com/HijackThis/3...-10379544.html
Hello there, if you notice that your PC is running a bit crazy, it maybe possible that computer is infected. In addition to viruses, your computer may be infected with Trojans, worms, adwares, viruses and other malwares. Also try http://www.kaspersky.com/virusscanner , let is scan your computer. With regards to pop-ups, have you tried simply using a pop-up blocker?
Hello there, if you notice that your PC is running a bit crazy, it maybe possible that computer is infected. In addition to viruses, your computer may be infected with spywares, Trojans, worms, adwares, viruses and other malwares. Please let us know what type of computer you have and also what anti-virus program you’ve used. Personally, if a PC is infected, I do recommend using more than one antiviris program to help you. My personal recommendation for cleanup softwares are : Adware SE, ACE, Avast, AVG, Mcafee, ParetoLogic XoftSpySE, PREVX and spyware be-gone. Also, I do recommend that you clean/restore your registry files…if these are corrupted, your PC will slow down. The software to help you with your registry: RegCure and Regpair. Some of the above mentioned programs can be downloaded at www.cnet.com. Please use these utilities and let’s know the outcome. The removal of viruses and other malwares does affect your PC registry.. Also try http://www.kaspersky.com/virusscanner , let is scan your computer. Do the following to post a hi-jack log which we'll address for you, you must first download the software from:http://www.download.com/HijackThis/3000-8022_4-10379544.html
Please list in details what's going on with your PC apart from it's going slow...is your internet explorer working...aqdditional pop-ups...ect....
Just a quick question...how long after it requests a scan does it log off? Also try http://www.kaspersky.com/virusscanner let is scan your computer. In addition to viruses, your computer may be infected with spywares, Trojans, worms, adwares, viruses and other malwares. Also, I do recommend that you clean/restore your registry files…if these are corrupted, your PC will slow down and have startup problems.
Ok guys...nice job...thx 4 all the help....i figured it out....
Please keep your anti-virus programs up to date and ensure that your firewall is enabled.
rather....it didn't work when i chose regular room
I did change the braces for the room options....still didn't work.....it didn't 'cout' the option for air-conditioned room....
#include<fstream>
#include<iomanip>
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double matric = 47.60;//matriculation fee
int hrz;//semester hours
char room;//room option
double regroom = 387.29;//rate for regular room
double acroom = 496.49;//rate for AC room
double dip = 38.00;//diploma fee
char grad;//graduation option
double food = 619.66;//rate for food
int stunum;//student ID #
double credit = 239.33;//cost of each semester hour
double totalcost;//student's total cost per semester
cout<<"Please enter the student #"<<endl;
cin>>stunum;
cout<<"What are the number of semester hours?"<<endl;
cin>>hrz;
cout<<"Please enter your Room Choice: (R/A)"<<endl;
cin>>room;
cout<<"Is the student graduating?: (Y/N)"<<endl;
cin>>grad;
cout<<stunum<<endl;
if (hrz>21)
{
cout<<"You are exceeding 21 semester hours"<<endl;
}
else if(hrz<12)
cout<<"You are taking less than 12 semester hours"<<endl;
double totalfeez = credit * hrz;//total fee for individual student
cout<<"Tuition: "<<totalfeez<<endl;
{
if (room == 'R')
cout<<"Room Type : Regular : "<<regroom<<endl;
else if (room == 'A')
cout<<"Room Type : Air-Conditioned : "<<acroom<<endl;
}
cout<<"Food : "<<food<<endl;
cout<<showpoint<<setprecision(4)<<"Matriculation : "<<matric<<endl;
{
if (grad = 'Y')
cout<<"Diploma fee : "<<dip<<endl;
else if (grad = 'N')
cout<<endl;
}
{
if (room = acroom)
totalcost = totalfeez + dip + matric + acroom + food;
else if (room = regroom)
totalcost = totalfeez + dip + matric + regroom + food;
}
cout<<setprecision(6)<<"Total Fees : "<<totalcost<<endl;
return 0;
}
A few problems: if i select 'N' for the graduation option...it still includes 'dip' into the total fees...The option, when I select 'R' for regular room...it doesn't 'cout' after it's compiled.
we'll stick with the free-ware stuff...actually i've used Xosft and it's pretty kool...and always remember to use more than one anti-spyware virus...
it works for air-conditioned room....but not for regular room
i guess the same would apply for the room option doesn't work....if i choose 'R' for room option...it prints out the letter...rather than the cost (but it does the calculation ok)...
ok..got it now....really appreciate it..it's working perfect now...have another assignment to post on wednesday...c u then...
does your pc have the requirements needed to run the game...if there's not enough memory (and points brought out by jabberwock486...) then chances are your system will definately freeze up.
ok...thx much..i see it...i had thought that when the user enters (A) which stands for acroom(air-conditioned room) it would automatically put the value of acroom in room adn thus carry out the calculation.
so....in addition to
double regroom = 387.29;
double acroom = 496.49;
, i'm going to have to refer to those values again in the loops?
ok....so i placed a 'cout' at the end of the statement....so it prints out the room (i.e. A or R) instead of the actual dollar amout...i'll figure it out...thx much.
My final problem....It compiles ok.....However, for the total cost, i don't see what's not working...I tried the following input: 22 semester hours, air-conditioned room, graduating. The total should be 6467.01 with the matricualtion fee and diploma fee (in this case the student is gaduating)....When i run the program..my total is 6035...My code below:
#include<fstream>
#include<iomanip>
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double matric = 47.60;//matriculation fee
int hrz;//semester hours
char room;//room option
double regroom = 387.29;//rate for regular room
double acroom = 496.49;//rate for AC room
double dip = 38.00;//diploma fee
char grad;//graduation option
double food = 619.66;//rate for food
int stunum;//student ID #
double credit = 239.33;//cost of each semester hour
cout<<"Please enter the student #"<<endl;
cin>>stunum;
cout<<"What are the number of semester hours?"<<endl;
cin>>hrz;
cout<<"Please enter your Room Choice: (R/A)"<<endl;
cin>>room;
cout<<"Is the student graduating?: (Y/N)"<<endl;
cin>>grad;
cout<<stunum<<endl;
if (hrz>21)
{
cout<<"You are exceeding 21 semester hours"<<endl;
}
else if(hrz<12)
cout<<"You are taking less than 12 semester hours"<<endl;
double totalfeez = credit * hrz;//total fee for individual student
cout<<"Tuition: "<<totalfeez<<endl;
{
if (room == 'R')
cout<<"Room Type : Regular : "<<regroom<<endl;
else if (room == 'A')
cout<<"Room Type : Air-Conditioned : "<<acroom<<endl;
}
cout<<"Food : "<<food<<endl;
cout<<"Matriculation : "<<matric<<endl;
{
if (grad == 'Y')
cout<<"Diploma fee : "<<dip<<endl;
else if (grad == 'N')
cout<<"No graduation this semester"<<endl;
}
double totalcost = totalfeez + dip + matric + room + food;
cout<<"Total Fees : "<<totalcost<<endl;
return 0;
}
I recommend a scan for spywares, Trojans, viruses, worms, adwares and other malwares. Also, I do recommend that you clean/restore your registry files…if these are corrupted, your PC will slow down. The software to help you with your registry: RegCure and Regpair. What happens when you try to open up Internest explorer? Please scan using the following website: http://www.pcflank.com/test.htm
After scan, it will let you know to some extent what area of your computer you need to check. (Ensure that your fire-wall is enabled)…Have a good day.
With regards to some websites logging off by themselves...they usually time-out...without your consent...A basic scan for spywares, Trojans, worms, adwares and other malwares is reccmm if you still don't feel safe. Also try : scan using the following website: http://www.pcflank.com/test.htm
After scan, it will let you know to some extent what area of your computer you need to check. Have a good day.
Please scan using the following website: http://www.pcflank.com/test.htm
After scan, it will let you know to some extent what area of your computer you need to check. Have a good day.
Please list the "wierd" things that are happening on your computer...please scan using the following website: http://www.pcflank.com/test.htm
After scan, it will let you know to some extent what area of your computer you need to check.
ok....thx Lerner.....big help...i'll make the necessary changes and repost my new code in a few.Ok guys....thx alot..i got it to work...really appreciate all the assistance..have a good weekend.
ok thanks...but my program won't compile...you you like for me to post the errors that i got from the compiler?
please let u sknow which program your using to compile it?
#include<fstream>
#include<iomanip>
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float matric = 47.60;//matriculation fee
int hrz;//semester hours
string room;//room option
float regroom = 387.29;//rate for regular room
float acroom = 496.49;//rate for AC room
float dip = 38.00;//diploma fee
string grad//graduation option
float food = 619.66;//rate for food
int stunum;//student ID #
float credit = 239.33;//cost of each semester hour
char R;//regular room
char A;//AC room
char Y;//Yes
char N;//No
cout<<"Please enter the student #"<<endl;
cin>>stunum;
cout<<"What are the number of semester hours?"<<endl;
cin>>hrz;
if (hrz>21)
cout<<"You are exceeding 21 semester hours"<<endl;
else if(hrz<12)
cout<<"You are taking less than 12 semester hours"<<endl;
cout<<"Please enter your Room Choice: (R/A)"<<endl;
cin>>room;
while (room == 'R')
cout<<"Regular : "<<regroom<<endl;
else if (room == 'A')
cout<<"Air-Conditioned : "<<acroom<<endl;
cout<<"Is the student graduating?: (Y/N)"<<endl;
cin>>grad;
while (grad == 'Y')
cout<<"Diploma fee : "<<dip<<endl;
else if (grad == 'N')
cout<<"No graduation this semester"<<endl;
cout<<stunum<<endl;
float totalfeez = credit * hrz;//total fee for individual student
cout<<totalfeez<<endl;
cout<<"Food : "<<food<<endl;
cout<<"Matriculation : "<<matric<<endl;
return 0;
}
This is what I kinna thought about..although it doesn't work...but that's kinna my idea as to how it would work....any help would be appreciated.
So far is what I've got:
#include<fstream>
#include<iomanip>
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float matric = 47.60;//matriculation fee
int hrz;//semester hours
float regroom = 387.29;//rate for regular room
float acroom = 496.49;//rate for AC room
float dip = 38.00;//diploma fee
float food = 619.66;//rate for food
int stunum;//student ID #
float credit = 239.33;//cost of each semester hour
char R;//regular room
char A;//AC room
char Y;//Yes
char N;//No
cout<<"Please enter the student #"<<endl;
cin>>stunum;
cout<<stunum<<endl;
cout<<"What are the number of semester hours?"<<endl;
cin>>hrz;
if (hrz>21)
cout<<"You are exceeding 21 semester hours"<<endl;
else if(hrz<12)
cout<<"You are taking less than 12 semester hours"<<endl;
float totalfeez = credit * hrz;//total fee for individual student
cout<<totalfeez<<endl;
cout<<"Please enter your Room Choice: (R/A)"<<endl;
cout<<"Is the student graduating?: (Y/N)"<<endl;
cout<<food<<endl;
cout<<matric<<endl;
cout<<dip<<endl;
return 0;
}
The assignment:
A local university charges 239.33 for each semester hour of credit., 387.29 per semester for a regular room, 496.49 for an air-conditioned room and 619.66 per semester for food. All students are charged a 47.60 matriculation fee. Graduating students must pay a diploma fee of 38.00.
Write a C++ program that will compute the fees that must be paid by a student. Input from the keyboard will be as follows:
Student # (a four digit #)
Number of semester hours
Room choice('R' for regular, 'A' for air-conditioned)
Graduating ('Y' for yes, 'N' for no)
After all input is typed in, then clear the screen. Output will be …
ok kool...thx much
My question is rather brief (it's similar to what is at http://www.daniweb.com/forums/thread79268.html). I've writen the program....but...i was just wondering (apart from the program itself) if there would be anyway to verify if what the program did is correct mathematically? I'll post my code if required. Thx and have a good day. Your suppose to write a C++ program that will add up all the odd numbers from 1 through 3579 and all of the even numbers from 522 through 2222. WHILE LOOPS MUST BE USED!!!
The output is to be in the format:
The sum of the odd numbers from 1-3579 is:
The sum of th eeven numbers from 522 through 2222 is:
i was just wondering (apart from the program itself) if there would be anyway to verify if what the program did is correct mathematically?
I guess that his professor was real adamant in him using while loops for the program instead of the good 'ol for loops...
#include<iostream>
#include<fstream>
#include<cstring>
#include<iomanip>
#include<cmath>
using namespace std;
struct Divsn
{
float first, second, third, fourth, total, avg;
string name;
};
int main()
{
const string N= "North";
const string W= "West";
const string S="South";
const string E="East";
const string NW="North West";
const string NE="North East";
const string SW="South West";
const string SE="South East";
ofstream outFile;
outFile.open("Company.dat");
Divsn div[8];
div[0].name=N;
div[1].name=W;
div[2].name=S;
div[3].name=E;
div[4].name=NW;
div[5].name=NE;
div[6].name=SW;
div[7].name=SE;
outFile<<"Division"<<setw(10)<<"1ST Quarter"<<setw(15)<<"2ND Quarter"<<setw(15)<<"3RD Quarter"<<setw(15)<<"4TH Quarter"<<setw(15)<<"Total"<<setw(15)<<"Average"<<endl;
for (int j=0; j<8; j++)
{
outFile<<setw(10)<<div[j].name;
cout<<"Please enter the the first quarter sales"<<div[j].name<<endl;
cin>>div[j].first;
while (div[j].first<0)
{
cout<<"No negative values please"<<endl;
cin>>div[j].first;
}
outFile<<fixed<<showpoint<<setprecision(2)<<setw(15)<<div[j].first;
cout<<"Please enter the the second quarter sales"<<div[j].name<<endl;
cin>>div[j].second;
while (div[j].second<0)
{
cout<<"No negative values please"<<endl;
cin>>div[j].second;
}
outFile<<fixed<<showpoint<<setprecision(2)<<setw(15)<<div[j].second;
cout<<"Please enter the the third quarter sales"<<div[j].name<<endl;
cin>>div[j].third;
while (div[j].third<0)
{
cout<<"No negative values please"<<endl;
cin>>div[j].third;
}
outFile<<fixed<<showpoint<<setprecision(2)<<setw(15)<<div[j].third;
cout<<"Please enter the the fourth quarter sales"<<div[j].name<<endl;
cin>>div[j].fourth;
while (div[j].fourth<0)
{
cout<<"No negative values please"<<endl;
}
outFile<<fixed<<showpoint<<setprecision(2)<<setw(15)<<div[j].fourth<<endl;
div[j].total=(div[j].first+div[j].second+div[j].third+div[j].fourth);
outFile<<setw(15)<<div[j].total;
div[j].avg= (div[j].total)/4.0;
outFile<<setw(15)<<div[j].avg<<endl;
outFile<<endl;
}
outFile.close();
return 0;
}
This is the code i came up with:
1. How can i use this same code, but use functions?
2. I get errors when i try to compile it
3. How can I print my report in descending order of Average quarterly sales.
Thank you and have a good day.
Thanks...I didn't post it as the assignment, i simply did it as an alternative to see if we had accomplished the same thing...but i'll post the code with the arrays structures soon. Where in this program could i use functions?
#include <iostream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include<cmath>
#include<cstring>
using namespace std;
float Efir,Esec, Ethir,Efour;
float Sfir,Ssec, Sthir,Sfour;
float Nfir,Nsec, Nthir,Nfour;
float Wfir, Wsec, Wthir,Wfour;
float NEfir,NEsec,NEthir,NEfour;
float SEfir,SEsec,SEthir,SEfour;
float NWfir,NWsec,NWthir,NWfour;
float SWfir,SWsec,SWthir, SWfour;
float WestTotal= Wfir + Wsec + Wthir + Wfour;
float EastTotal= Efir + Esec + Ethir + Efour;
float NorthTotal= Nfir + Nsec + Nthir + Nfour;
float SouthTotal= Sfir + Ssec + Sthir + Sfour;
float NorthEastTotal= NEfir + NEsec + NEthir + NEfour;
float NorthWestTotal= NWfir + NWsec + NWthir+ NWfour;
float SouthEastTotal = SEfir + SEsec + SEthir + SEfour;
float SouthWestTotal= SWfir + SWsec+ SWthir + SWfour;
float EastAverage= (Efir + Esec + Ethir + Efour)/4;
float WestAverage= (Wfir + Wsec + Wthir + Wfour)/4;
float NorthAverage=(Nfir + Nsec + Nthir + Nfour)/4;
float SouthAverage= (Sfir + Ssec + Sthir + Sfour)/4;
float NorthEastAverage=(NEfir+NEsec + NEthir+NEfour)/4;
float NorthWestAverage=(NWfir+NWsec+NWthir+NWfour)/4;
float SouthEastAverage= (SEfir+SEsec+SEthir+SEfour)/4;
float SouthWestAverage= (SWfir+SWsec+SWthir+SWfour)/4;
int main()
{
cout<<"Enter Four Quarter Scores for Division East, separated by space: "<<endl;
cin>>Efir>>Esec>>Ethir>>Efour;
EastTotal= Efir + Esec + Ethir + Efour;
EastAverage= (Efir + Esec + Ethir + Efour)/4;
if (Efour, Esec, Ethir, Efour<0)
cout<<" No negative numbers allowed !!"<<endl;
else
{
cout<<EastTotal<<" The average is: "<<EastAverage<<endl;
}
cout<<"Enter Four Quarter Scores for Division North, separated by space: "<<endl;
cin>>Nfir>>Nsec>>Nthir>>Nfour;
NorthTotal= Nfir + Nsec + Nthir + Nfour;
NorthAverage=(Nfir + Nsec + Nthir + Nfour)/4;
if (Nfir, Nsec, Nthir, Nfour<0)
cout<<"No negative numbers allowed !!"<<endl;
else
{
cout<<NorthTotal<<" The average is: "<<NorthAverage<<endl;
}
cout<<"Enter …
How about something like this:
#include <iomanip>
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
void TotalAverage(int i, int j);
void giveDivision(int i);
void Enter_Fourth_Quarter_Score();
int array[Divisions][Quarters];
void sort(int Arrayavg[8]);
int printResult();
void deleteresult();
double EastTotal= 0, WestTotal= 0,NorthTotal= 0, SouthTotal= 0,
NortEastTotal= 0, NorthWestTotal= 0, SouthEastTotal= 0,
SouthWestTotal= 0;
double EastAverage = 0, WestAverage = 0, NorthAverage = 0, SouthAverage = 0,
NortEastAverage = 0, NorthWestAverage = 0, SouthEastAverage = 0,
SouthWestAverage = 0;
double East, West, North, South, NortEast, NorthWest, SouthEast, SouthWest;
const string N = "North Division";
const string S = "South Division";
const string E = "East Division";
const string W = "West Division";
const string NW = "North West Division";
const string NE = "North East Division";
const string SW = " South West Division";
const string SE = " South East Division";
int main()
{
char Month[20];
int Day, Year, i, j;
ofstream outFile;
outFile.open ("outsales.dat")
Divisions div[8]
Quarters[8]
div [0].name= N;
div [1].name= S;
div [2].name= E;
div [3].name= W;
div [4].name= NW;
div [5].name= NE;
div [6].name= SW;
div [7].name = SE;
outFile<<setw(10)<<"Division"<<setw(15)<<"First Quarter"<<setw(15)<<"Second Quarter"<<setw(15)<<"Third Quarter"<<setw(15)<<"Fourth Quarter"<<setw(15)<<"Total"<<setw(15)<<"Average"<<endl;
for (int j=0; j<8; j++)
cout << " Enter Fourth Quarter Score for Division NortEast"
<< '\n';
cin >> NortEast;
}while (NortEast < 0);
//the following will ask the user to input Fourth Quarter sales
//ensure that the value entered is a positive value
do{
cout << " Enter Fourth Quarter Score for Division NorthWest"
<< '\n';
cin >> NorthWest;
}while (NorthWest < …
there are softwares out there such as “Explorer Repair” that resets your TCP/IP settings, deletes ARP Cache, repair your host files, checks your winsock files . I recommend posting a Jack-log. Please download FixWareout from this site:
http://www.bleepingcomputer.com/file...Fixwareout.exe and then re-post your hijack log.
never mind- i got it figured out..thx a lot, i didn't see it until now. I see now that its logical it is because each time the program goes through the loop it's gonna print out the headers because it's part of the loop....thx for the tip...now i have a question not related to C++....can you delete a post after it's solved? Also, how long are threads/post stayed online? If you don't log into your account every so often, will it expire after a while? Thnx.
I need a second pair of eyes please:
my Code:
#include<fstream>
#include<iomanip>
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int stunum;//# of students in the class
string stuname;// Name of the student
float Test1;//score for test 1
float Test2;//score for test 2
float Midterm;//score for midterm
float Final;//score for final
float Term;//score for term project
float Grade;
float NumA=0;
float NumB=0;
float NumC=0;
float NumF=0;
float Avg1;
float Avg2;
float Avg3;
float Avg4;
ifstream inFile;
ofstream outFile;
inFile.open ("ClassData.dat");
outFile.open ("ClassOutput");
inFile>>stunum;//reads in the # of students in the class
outFile<<"The # of students in the class:"<<stunum<<endl;
for (int j=0; j<stunum; j++)
{
inFile>>stuname>>Test1>>Test2>>Midterm>>Final>>Term;
Avg1=((Test1+Test2)/2*(.2));//Calculate average test score
Avg2=(Midterm*(.25));//Calculate average midterm score
Avg3=(Final*(.3));//calculate the final
Avg4=(Term*(.25));
Grade= Avg1+Avg2+Avg3+Avg4;
{
if(Grade>=90)
{
outFile<<setw(15)<<" A ";
NumA++;
}
else if (Grade>=80)
{
outFile<<setw(15)<<" B ";
NumB++;
}
else if (Grade>=70)
{
outFile<<setw(15)<<" C ";
NumC++;
}
else if (Grade<70)
{
outFile<<setw(15)<<" F ";
NumF++;
}
}
outFile<<setw(10)<<"Name"<<setw(10)<<"Test1"<<setw(10)<<"Test2"<<setw(10)<<"Midterm"<<setw(10)<<"Final"<<setw(14)<<"Project"<<setw(14)<<"Total Grade"<<setw(14)<<"Letter Grade"<<endl;
outFile<<"********************************************************************************************"<<endl;
outFile<<setw(10)<<stuname<<setw(10)<<Test1<<setw(10)<<Test2<<setw(10)<<Midterm<<setw(10)<<Final<<setw(14)<<Term<<setw(14)<<Grade;
}
outFile<<endl<<endl;
outFile<<"The # of A's: "<<NumA<<endl;
outFile<<"The # of B's: "<<NumB<<endl;
outFile<<"The # of C's: "<<NumC<<endl;
outFile<<"The # of F's: "<<NumF<<endl;
inFile.close();
outFile.close();
return 0;
}
my outFile:
The # of students in the class:10
F Name Test1 Test2 Midterm Final Project Total Grade Letter Grade
********************************************************************************************
Gayle 75 82 62 61 59 64.25 F Name Test1 Test2 Midterm Final Project Total Grade Letter Grade
********************************************************************************************
Brown 79 100 17 19 89 50.1 B Name Test1 Test2 Midterm Final Project …
Ptarila....thx for the help-but i have to use a FOR loop, i'm currently making modifications to my code and will see if i get it to work. thx a lot
I did a bit of fixing, still having the problem of the outFile only having info for Kennez. Any ideas welcomed...thanks and have a good day.
I had placed the wrong inFile:
Gayle 75 82 62 61 59
Brown 79 100 17 19 89
Byles 100 94 81 79 81
Watts 71 22 48 100 17
Walsh 41 85 71 88 81
Ahmed 93 47 76 64 94
Ellis 87 99 100 70 83
Silny 80 76 85 78 81
Simms 88 93 42 84 65
Kenez 75 48 77 69 82
------------------------------------------------------
My instructor said i could only use a FOR loop
#include<fstream>
#include<iomanip>
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int stunum;//# of students in the class
string stuname;// Name of the student
float Test1;//score for test 1
float Test2;//score for test 2
float Midterm;//score for midterm
float Final;//score for final
float Term;//score for term project
float Grade;
float NumA=0;
float NumB=0;
float NumC=0;
float NumF=0;
ifstream inFile;
ofstream outFile;
inFile.open ("ClassData.dat");
outFile.open ("ClassOutput");
inFile>>stunum;//reads in the # of students in the class
outFile<<"The # of students in the class:"<<stunum<<endl;
for (int j=0; j<stunum; j++)
inFile>>stuname>>Test1>>Test2>>Midterm>>Final>>Term;
Grade= Test1+Test2+Midterm+Final+Term;
Grade=Grade/5;
inFile>>stuname>>Test1>>Test2>>Midterm>>Final>>Term;
{
{ outFile<<setw(10)<<"Name"<<setw(10)<<"Test1"<<setw(10)<<"Test2"<<setw(10)<<"Midterm"<<setw(10)<<"Final"<<setw(12)<<"Project"<<setw(14)<<"Total Grade"<<setw(14)<<"Letter Grade"<<endl;
outFile<<setw(10)<<stuname<<setw(10)<<Test1<<setw(10)<<Test2<<setw(10)<<Midterm<<setw(10)<<Final<<setw(10)<<Term<<setw(13)<<Grade<<endl;
{
float Grade= Test1+Test2+Midterm+Final+Term;
Grade=Grade/5;
if(Grade>=90)
{
outFile<<"A ";
NumA++;
}
else if (Grade>=80)
{
outFile<<"B ";
NumB++;
}
else if (Grade>=70)
{
outFile<<"C ";
NumC++;
}
else if (Grade<70)
{
outFile<<"F ";
NumF++;
}
inFile>>stuname>>Test1>>Test2>>Midterm>>Final>>Term;
}
outFile<<"The # of A's:"<<NumA<<endl;
outFile<<"The # of B's:"<<NumB<<endl;
outFile<<"The # of C's:"<<NumC<<endl;
outFile<<"The # of F's:"<<NumF<<endl;
}
}
inFile.close();
outFile.close();
return 0;
}
My inFile:
10
Gayle 86 88 92 96 78
Brown 47 40 57 29 49
Byles 61 49 28 52 71
Holst 71 82 78 70 69
Welsh 71 54 55 80 68
Hamms 93 77 86 74 84
Ellis 88 96 80 87 73
Spear 100 100 85 88 91
Wilks 48 53 62 74 75
Bolop 65 74 73 82 51
My outFile shows like tgis however:
The # of students in the class:10
Name Test1 …