Welcome aboard…..hope you’ll enjoy it here…..well, start posting!!!
iamthwee commented: wtf is that! -2
zandiago 115 Nearly a Posting Maven Featured Poster
Welcome aboard…..hope you’ll enjoy it here…..well, start posting!!!
Good day. Sorry to hear about your dilema. Let's just start off with a few basic things so we could assist you better:
1. When you boot so you see the message that says: "Please select the operating system to start?" or do you hear any beep?
2. Which version of windows are you using? Have you contacted the manufacturers?
3. The Boot.ini file may be corrupted.
4. Possible that a boot sector/record may be damaged.
Good luck!
You may wanna post you've tried thus far.
Is this an school assignment? I'm really sorry if i seem too harsh, I'm still learning c++,but some of the real pro's here won't even bother helping you if you're code isn't formatted properly...they'll just move on. I strongly recomend if you wanna learn c++, stick around.... there are other books that are great for new-comers like you. Also, there are great tutorials here, you can use to get you started....most importantly....don't give up....it can be frustrating at times.....cheer up mate.
Oh goodness....how did you get quote tags in there?? Your formatting should use at the beginning"["CODE=CPLUSPLUS"]" & "["/CODE"]" at the end...
Back to your assignment:
So is the user going to enter all four quarters at once?? I recommend you breaking it down like how i showed in my previous post. Where are your calcualtions for the average??? You're FOR loop, may look something like this, so it can go through all the quarters of the division:
for (int j=0; j<6; j++)
At the begining of your code place:
"["CODE=cplusplus"]", without the ". This way its easier to read...back to your assignment....
16 cout <<"Enter the following sales information:\\n\n";
Given the requirement of your assignment, you may want to break down your program a bit more...example:
cout<< "Please enter First Qrt Sales"<<div[j].name<<endl;
cin>>div[j].fir;
cout<< "Please enter Second Qrt Sales"<<div[j].name<<endl;
cin>>div[j].sec;
cout<< "Please enter Third Qrt Sales"<<div[j].name<<endl;
cin>>div[j].thir;
cout<< "Please enter Fourth Qrt Sales"<<div[j].name<<endl;
cin>>div[j].four;
You'll also need the following header for mathematical calculations(averages..ect...)
#include <cmath>
11 double totalSales = 0; //To hold the total sales.
This is to calculate Total sales...not to store it.
2.Where are the headers/titles i pointed out in my previous post? Where is your loops? You've still got quite a bit of work...
Please format your code:
At the begining of your code place:
"["CODE=cplusplus"]"
PLACE CODE HERE
At the end of your code, place "["/CODE"]"...without the "
In other words....can you please post what you've got so far?
You're absoluately right. We won't give you a complete code, but we'll help and provide pointers. Firstly, welcome aboard. I can give you a head start, although i wish you'd read up on arrays. You need to tell us if the program is doing to be interactive, will it read data from the infile???
A few things:
1. You can start by delcaring a few variables that you'll need:
struct Comp;
float first;
float second;
float third;
float value;
float average;
2. With regards to the six divisions...for example, if it's the same company, they perhaps are divided as such:
string const N = "North Division";
string const S = "South Division";
string const E = "East Division";
string const W = "West Division";
3. Then for the arrays, you may do something like:
Comp div[4]
div [0].name= N;
div [1].name= S;
div [2].name= E;
div [3].name= W;
4. Create a titles/headers to show your output data:
cout<<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;
5. Use a FOR loop to go through each division.
6. Do calculation to carry out the averages.
Hope this helps, I know that C++ at times may be overwhelming, but write it out on scratch-paper first to see exactly what you'll need to do. I gave you a jumpstart. You'll also need to provide more information about the requirements of your assignment.
Given which equations? Please post what you've come up with, so we can review your code and show you whats wrong. Welcome aboard!
I'd go with the softwares that will unlock the admins password upon boot-up....if you know what you're doing...if its a new computer and you've got nothing too important on it....i'd say just reinstall windows...i don't think it will require a password.
Thx again man. Problem solved and program works like a charm.
In the method of formatting that i had suggested...do it exactly, just leave out the " . Also, if you've got your desired answer, and your satisfied, please mark this thread as being SOLVED(option at the bottom of this page). This prevents from making people continually looking at and trying to solve the post again. Hope you'll enjoy the Forum.
This specific problem has been addressed before. In the future, please search the forum before you post, chances are that someone else had that assignment/problem. Please take a look at the following thread for some guidance:
http://www.daniweb.com/forums/thread49939.html
Hope that help and welcome aboard. By the way, as a new person, you did good in the proper way of posting in terms of formating with code tags. Except, in the furure:
before adding your code, use ["code=cplusplus"]
code here
and use ["/code"] when your done. This way it number your code, so when you start doing longer/harder assignments we can follow your code line by line.
Ok, this is what i tried.I'm trying to calculate the class average and I want it print at the bottom after i've shown the records & grades for the students:
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
int check_correct_answers(string answerKey, string studentAnswers);
void display_student_grade(int score);
void classAV(double classaverage,int sumgrades, int score);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open("tftest.txt");
outFile.open("testout");
int score=0;
string answerKey;
string studentID;
string studentAnswers;
int sumgrades=0;
double classaverage=0;
getline(inFile, answerKey);
cout<<"The correct answers "<<answerKey << endl<<endl;
while (getline(inFile, studentID))
{
cout << studentID <<" ";
getline(inFile, studentAnswers);
cout << studentAnswers<<" ";
score = check_correct_answers(answerKey, studentAnswers);
display_student_grade(score);
classAV(classaverage,sumgrades,score);
}
return 0;
}
int check_correct_answers(string answerKey, string studentAnswers)
{
int i, correct = 0, incorrect = 0, blank = 0;
int score=0;
for (i = 0; i < 23 - 1; i++)
{
if (answerKey[i] == studentAnswers[i])
correct++;
if (answerKey[i] != studentAnswers[i])
incorrect++;
if (studentAnswers[i] == ' ')
{
blank++;
incorrect--;
}
score = (correct * 5) + (incorrect * (-2))+ (blank *( -4));
}
cout << score<<" ";
return score;
}
// PRINT OUT STUDENT GRADES
void display_student_grade(int score)
{
if (score >= 90)
cout<<"A"<<endl;
else if (score< 90 && score > 79)
cout<< "B"<<endl;
else if (score <= 79 && score > 69)
cout<< "C"<<endl;
else if (score <= 69 && score > 60)
cout<< "D"<<endl;
else if (score <= 59)
cout<< "F"<<endl;
}
void classAV(double classaverage, int sumgrades, int score)
{
sumgrades = 0.0;
sumgrades += score;
classaverage = (sumgrades/23); …
Ok, thx for the feedback.
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
int check_correct_answers(string answerKey, string studentAnswers);
void display_student_grade(int score);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open("tftest.txt");
outFile.open("testout");
int score=0;
string answerKey;
string studentID;
string studentAnswers;
getline(inFile, answerKey);
cout<<"The correct answers "<<answerKey << endl<<endl;
while (getline(inFile, studentID))
{
cout << studentID <<" ";
getline(inFile, studentAnswers);
cout << studentAnswers << endl;
score = check_correct_answers(answerKey, studentAnswers);
display_student_grade(score);
}
return 0;
}
int check_correct_answers(string answerKey, string studentAnswers)
{
int i, correct = 0, incorrect = 0, blank = 0;
int score=0;
for (i = 0; i < 23 - 1; i++)
{
if (answerKey[i] == studentAnswers[i])
correct++;
if (answerKey[i] != studentAnswers[i])
incorrect++;
if (studentAnswers[i] == ' ')
{
blank++;
incorrect--;
}
score = (correct * 5) + (incorrect * (-2))+ (blank *( -4));
}
cout << score<<" ";
return score;
}
// PRINT OUT STUDENT GRADES
void display_student_grade(int score)
{
if (score >= 90)
cout<<"A"<<endl;
else if (score< 90 && score > 79)
cout<< "B"<<endl;
else if (score <= 79 && score > 69)
cout<< "C"<<endl;
else if (score <= 69 && score > 60)
cout<< "D"<<endl;
else if (score <= 59)
cout<< "F"<<endl;
}
Now it comes out ok....However will i have to create a separate function to calcualte the average for the entire class?
Thx again guys.
Ok thanx m8.
A rather silly question i've got:
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
int check_correct_answers ( string answerKey, string studentAnswers, char grade, int score);
char display_student_grade( int score);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("tftest.txt");
outFile.open ("testout");
int score=0;
char grade;
string answerKey;
string studentID;
string studentAnswers;
getline(inFile, answerKey);
cout<<"The correct answers "<<answerKey << endl<<endl;
while(getline(inFile, studentID))
{
cout << studentID <<" ";
getline(inFile, studentAnswers);
cout << studentAnswers << endl;
}
display_student_grade(score);
check_correct_answers(answerKey,studentAnswers,grade,score);
return 0;
}
int check_correct_answers( string answerKey, string studentAnswers,char grade,int score)
{
int i, correct = 0, incorrect = 0, blank = 0;
for (i = 0; i < 23 - 1; i++)
{
if (answerKey[i] == studentAnswers[i])
correct++;
if (answerKey[i] != studentAnswers[i])
incorrect++;
if (studentAnswers[i] == ' ')
{
blank++;
incorrect--;
}
score = (correct * 5) + (incorrect * (-2)) + (blank *( -4));
}
cout << score << endl;
return score;
}
// PRINT OUT STUDENT GRADES
char display_student_grade( int score )
{
int i;
for (i = 0; i < 30; i++)
{
if (score >= 90)
cout<<"A"<<endl;
else if (score < 90 && score > 79)
cout<< "B"<<endl;
else if (score <= 79 && score > 69)
cout<< "C"<<endl;
else if (score <= 69 && score > 60)
cout<< "D"<<endl;
else if (score <= 59)
cout<< "F"<<endl;
}
return 0;
}
My output:
The correct answers TFFTFFTFFTFFTFTFTFTFFF
A33 TFFTFFTFFFFFTFTFTFFFFT
Z27 TFFTFFTFFTFFTFTFTFTFFT
X12 TFTT FTFFTFFFT FTFTFFF
H44 TFFTFFTFFTFFFFTFTFFTFF
Q19 FFFFFFFFFFFFTFTFTFFFFF
D72 …
Have you tried anything? Why would you need such a program, the folder options and microsoft word has security options to password protect a document?
Good day. Here is my revised code:
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("food.txt");
outFile.open ("foodout");
char letter[30];
string item[30];
double cost[30];
double taxrate = 0.06;
double costOfselections=0;
for(int i = 0; i < 30; ++i)
{
inFile >> letter[i];
inFile.ignore();
getline(inFile, item[i]);
inFile >> cost[i];
}
char selections[100];
//instructions to enter menu selections
cout << "enter selections, on letter per selection" << endl;
cout << "press the = key followed by the enter key to stop entry and print bill" << endl;
cin.getline(selections, 99, '=');
int numSelections = strlen(selections);
double costOfSelections = 0.0;
int index;
for(int i = 0; i < numSelections; ++i)
{
for(int j =0; j < 30; ++j)
if (i = j)
i = index;
}
//calculate tax and total price
double tax = (costOfselections * taxrate);
double subtotal = (costOfselections + tax);
double amount_tendered;
cin>>amount_tendered;
if (amount_tendered<subtotal)
{
cout<<"You need more funds!"<<endl;
}
else
{
//Display receipt
cout<<endl;
cout<<"Zandiago’s Z-BURGER SHACK"<<endl;
cout<<"Amount"<<cost<<endl;
cout<<"6 % Sales Tax"<<tax<<endl;
cout<<"============================================"<<endl;
cout<<"Total"<<subtotal<<endl;
cout<<"Amount tendered"<<amount_tendered<<endl;
cout<<"Change"<<(amount_tendered-subtotal)<<endl;
cout<<"Thank you for visiting"<<endl;
cout<<"Zandiago's Z-Burger Shack"<<endl;
}
return 0;
}
I have a few questions. I wanted tge program, each time a customer chooses an item, for it to be displayed as he/she chooses. It's also telling me that index is undeclared. I wanted the output to look something like:
Example of output
Zandiago’s Z-BURGER SHACK
Date: Oct 25-07 Time: 18:31:26
Hamburger .............................. 2.45
Salad, Regular ......................... …
What does the error message mean?
1>Linking...
1>grading.obj : error LNK2019: unresolved external symbol "int __cdecl check_correct_answers(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,char,double)" (?check_correct_answers@@YAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0DN@Z) referenced in function _main
1>C:\Users\Documents\Visual Studio 2008\Projects\grading\Debug\grading.exe : fatal error LNK1120: 1 unresolved externals
The code i had before wasn't the entire code..it was just the main function. This is my whole code:
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
int check_correct_answers ( char *answerKey, char *studentAnswers, char *grade, double score);
char display_student_grade( int score);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("tftest.txt");
outFile.open ("testout");
double score = 0;
char grade;
string answerKey;
string studentID;
string studentAnswers;
display_student_grade(score);
getline(inFile, answerKey);
cout<<"The correct answers "<<answerKey << endl<<endl;
while(getline(inFile, studentID))
{
cout << studentID <<" ";
getline(inFile, studentAnswers);
cout << studentAnswers << endl;
}
return 0;
}
int check_correct_answers( char *answerKey, char *studentAnswers, int score, char grade)
{
int i, correct = 0, incorrect = 0, blank = 0;
for (i = 0; i < 23 - 1; i++)
{
if (answerKey[i] == studentAnswers[i])
correct++;
if (answerKey[i] != studentAnswers[i])
incorrect++;
if (studentAnswers[i] == ' ')
{
blank++;
incorrect--;
}
score = (correct * 5) + (incorrect * (-2)) + (blank *( -4));
}
cout << score << endl;
return score;
}
// PRINT OUT STUDENT GRADES
char display_student_grade( int score )
{
int i;
for (i = 0; i < 30; i++)
{
if (score >= 90)
cout<<"A"<<endl;
else if (score < 90 && score > 79)
cout<< "B"<<endl;
else if (score <= 79 && score > 69)
cout<< "C"<<endl;
else if (score <= 69 && score > 60)
cout<< "D"<<endl;
else if (score <= 59)
cout<< "F"<<endl;
}
return 0;
}
Missed that one Lerner....thx...let me repost....at this point i'm still getting the data and the students records, i'm just working on the function to compare the answerKey to the students actual grade.
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
int check_correct_answers ( char *answerKey, char *studentAnswers, char *grade, double score);
char display_student_grade( int score);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("tftest.txt");
outFile.open ("testout");
double score = 0;
char grade;
string answerKey;
string studentID;
string studentAnswers;
display_student_grade(score);
getline(inFile, answerKey);
cout<<"The correct answers "<<answerKey << endl<<endl;
while(getline(inFile, studentID))
{
cout << studentID <<" ";
getline(inFile, studentAnswers);
cout << studentAnswers << endl;
}
return 0;
}
i guess because of how i've got my functions, it prints out a bunch of F's for the grades?
I did try to change it as you pointed out WaltP...but then i got:
1>c:\users\documents\visual studio 2008\projects\grading\grading\grading.cpp(34) : error C2664: 'check_correct_answers' : cannot convert parameter 1 from 'std::string' to 'char []'
Nice illustration....this is most recent post:
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
int check_correct_answers ( char answerKey[], char studentAnswers[], char grade, double score);
char display_student_grade( int score);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("tftest.txt");
outFile.open ("testout");
double score = 0;
char grade;
string answerKey;
string studentID;
string studentAnswers;
check_correct_answers (answerKey[] , studentAnswers[] , grade, score);
display_student_grade(score);
getline(inFile, answerKey);
cout<<"The correct answers "<<answerKey << endl<<endl;
while(getline(inFile, studentID))
{
cout << studentID <<" ";
getline(inFile, studentAnswers);
cout << studentAnswers << endl;
}
return 0;
}
int check_correct_answers( char answerKey[], char studentAnswers[], int score, char grade)
{
int i, correct = 0, incorrect = 0, blank = 0;
for (i = 0; i < 23 - 1; i++)
{
if (answerKey[i] == studentAnswers[i])
correct++;
if (answerKey[i] != studentAnswers[i])
incorrect++;
if (studentAnswers[i] == ' ')
{
blank++;
incorrect--;
}
score = (correct * 5) + (incorrect * (-2)) + (blank *( -4));
}
cout << score << endl;
return score;
}
// PRINT OUT STUDENT GRADES
char display_student_grade( int score )
{
int i;
for (i = 0; i < 30; i++)
{
if (score >= 90)
cout<<"A"<<endl;
else if (score < 90 && score > 79)
cout<< "B"<<endl;
else if (score <= 79 && score > 69)
cout<< "C"<<endl;
else if (score <= 69 && score > 60)
cout<< "D"<<endl;
else if (score <= 59)
cout<< "F"<<endl;
}
return 0;
}
It however, gives me:
1>Compiling...
1>grading.cpp
1>c:\users\documents\visual studio 2008\projects\grading\grading\grading.cpp(34) : error C2059: syntax …
Actually, i know of a doctor who visited one of the islands in the caribbean and he says, he visits there often to use marijuana because he benefits from it...that's from a doctor...additionally, it has been used to make clothing....i've seen someone used it to cure a sore they had on their foot.
curry chicken, with rice and a bottle of whisky..
Am i not allowed to do this in the main function:
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("tftest.txt");
outFile.open ("testout");
double score = 0;
char grade;
string answerKey;
string studentID;
string studentAnswers;
check_correct_answers (answerKey[] , studentAnswers[] , grade, score);
display_student_grade(score);
getline(inFile, answerKey);
cout<<"The correct answers "<<answerKey << endl<<endl;
while(getline(inFile, studentID))
{
cout << studentID <<" ";
getline(inFile, studentAnswers);
cout << studentAnswers << endl;
}
return 0;
}
Thanks for responding....i dunno what's missing. Aren't my two functions that i have there suppose to provide me with the letter and number grade:
int check_correct_answers( char answerKey[], char studentAnswers[], int score, char grade)
&
char display_student_grade( int score )
This is what it has come down to:
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
int check_correct_answers ( char answerKey[], char studentAnswers[], char grade, double score);
char display_student_grade( int score);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("tftest.txt");
outFile.open ("testout");
double score;
char grade;
string answerKey;
string studentID;
string studentAnswers;
getline(inFile, answerKey);
cout<<"The correct answers "<<answerKey << endl<<endl;
while(getline(inFile, studentID))
{
cout << studentID <<" ";
getline(inFile, studentAnswers);
cout << studentAnswers << endl;
}
return 0;
}
int check_correct_answers( char answerKey[], char studentAnswers[], int score, char grade)
{
int i, correct = 0, incorrect = 0, blank = 0;
for (i = 0; i < 23 - 1; i++)
{
if (answerKey[i] == studentAnswers[i])
correct++;
if (answerKey[i] != studentAnswers[i])
incorrect++;
if (studentAnswers[i] == ' ')
{
blank++;
incorrect--;
}
score = (correct * 5) + (incorrect * -2) + (blank * -4);
}
cout << score << endl;
return score;
}
// PRINT OUT STUDENT GRADES
char display_student_grade( int score )
{
int i;
for (i = 0; i < 30; i++)
{
if (score >= 90)
cout<<"A"<<endl;
else if (score < 90 && score > 79)
cout<< "B"<<endl;
else if (score <= 79 && score > 69)
cout<< "C"<<endl;
else if (score <= 69 && score > 60)
cout<< "D"<<endl;
else if (score <= 59)
cout<< "F"<<endl;
}
return 0;
}
My two problems:
It doesn't show the numeric grade beside the persons info, nor the student's letter grade equivalent. It does …
score = calculateStudentScore(answerKey, studentAnswers);
grade = determineStudentGrade(score);
Ok guys thanks for the feedback...i've taken both suggestions and will be making own program. But Lerner, what do the two above lines do?
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
const int ANSWER_SIZE = 23;
int check_correct_answers( char [], char [] );
int check_incorrect_answers( char [], char [] );
int check_no_answer( char [], char [] );
char display_student_grade( int );
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("tftest.txt");
outFile.open ("testout");
char student_id[4];
char test_answers[23];
char student_answers[ANSWER_SIZE];
double score;
while (getline(inFile, test_answers))
{
cout << "Test answers: " << test_answers << endl;
cout << "Student answers: " << student_answers << endl;
}
while(getline(inFile, student_id))
{
cout << " " << student_id;
cout << " " << student_answers;
cout << " " << check_correct_answers( test_answers, student_answers ) << " "
<< display_student_grade( check_correct_answers( test_answers, student_answers ) ) << endl;
}
return 0;
}
// CHECK ANSWERS TO TEST
int check_correct_answers( char test_answers[], char student_answers[])
{
int i, correct = 0, incorrect = 0, blank = 0, score = 0;
for (i = 0; i < ANSWER_SIZE - 1; i++)
{
if (test_answers[i] == student_answers[i])
correct++;
if (test_answers[i] != student_answers[i])
incorrect++;
if (student_answers[i] == ' ')
{
blank++;
incorrect--;
}
score = (correct * 5) + (incorrect * -2) + (blank * -4);
}
return score;
}
// PRINT OUT STUDENT GRADES
char display_student_grade( int student_score )
{
int i;
for (i = 0; i < 10; i++)
{
if (student_score >= 90)
return 'A';
else if (student_score < 90 && student_score > 79)
return 'B';
else if (student_score <= 79 && student_score > 69)
return 'C';
else if (student_score …
Well....coorporate leaders are really something else too...they'll say the company is loosing money....so they cut staff, export jobs, mergre departments, cut your bonus by 1/2....let one person do the job of 10 people....yet their salaries and bonuses never seem to change...always amazes me.
..in other words, i heard that the two languages are similar and are different in other respects(such as speed and efficiency). What i was reffering to was are the commands the same, headers, mathematical calculations...ect....I didn't need you to convert the entire program...i'm not studying java.
Yes, politicans are corrupt, yet people are so blind to see this...some make big promises to get votes and then when they get into power, they at times forget about them...but a few years down the road....they are voted back into office...
Good day. How do i convert the following code to C++?
// Lets import our file functions.
import java.io.*;
public class Grades {
// Setup an array of test students
private static Grades.test student[] = new Grades.test[50];
// Just for spunk we will create an inner class to keep this in one file.
private static class test {
public String id = "";
public String answer = "";
public double score = 0.0;
public double grade = 0.0;
}
public static void main(String args[])
{
int total=0;
// initialize(); This was removed because we initialize when we create students.
getdata();
int i = 1;
// Loop through students until we reach our 50 limit or there were not that many in our class to begin with.
while ((i < student.length - 1) && (student[i] != null))
{
total = 0;
for(int j = 0; j < 22; j++)
{
// Here we are going to check student answer against "master key" student (at index 0)
if(student[0].answer.substring(j,j+1).equals(student[i].answer.substring(j,j+1)))
{
total = total + 5;
}
else if(student[i].answer.substring(j,j+1).equals(" "))
{
total = total - 4;
}
else
{
total = total - 2;
}
}
// Obviously if they end up leaving all blank or go negative, they get a zero for the grade.
if (total < 0) { total = 0; }
// Here we print out the student id, their answers and total points (not grade point average!)
System.out.println(student[i].id + " " + student[i].answer + " " + total);
i++; …
where do i go from here?
where do i go from here?
try to change the boot settings from Hard-drive to allow it to boot from the CD (given that you've got the windows XP CD). Could you be more detailed. So when you turn you're laptop on, does it just say that the hard-drive it right protected and that's it? How far does the booting go?
Thx for catching the sytax. I've corrected that, i'm just a bit of problems with your second part of your above-mentioned suggestion. Thx for your input.
Lerner....some some of the posts that i read, i see you're a strong beleiver of using vectors. I had tried to compile a program using DEV C++, in which i used vectors and it didn't compile...but the same program worked in microsoft's visual c++...unfortunately, my professor uses DEV C++ to check all assignments. Thx though for your input & also to you WaltP.
Good day:
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
using namespace std;
void initialize(char test, int sstudent[30]);
void getdata(char test, int sstudent[30]);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("tftest.txt");
outFile.open ("testout");
int i, j, k;
int total=0;
char test;
int student[30];
initialize(test,student);
getdata(test,student);
for(i = 2; i < 30; i = i + 2)
{
for(j = 0; j < 22; j++)
{
cout << student[0].answer.substr(j,1);
if(student[0].answer.substr(j,1) == student[i].answer.substr(j,1))
{
total = total + 5;
}//end if
else if(student[i].answer.substr(j,1) == " ")
{
total = total - 4;
}//end else
else
{
total = total - 2;
}//end else
}//end for
}//end for
return 0;
}// end of main function
//********************************** Function Definitions
void initialize(test sstudent[30])
{
int i;
for(i = 1; i < 30; i++)
{
sstudent[i].id = "";
sstudent[i].answer = "";
}//end for
}//end initialize
//***********************************
void getdata(test sstudent[30])
{
int i;
getline(infile, sstudent[0].answer);
for(i = 1; i < 30; i++)
{
getline(infile, sstudent[i].id);
getline(infile, sstudent[i].answer);
}//end for
infile.close();
}//end getdata
//************************************
Considering the fact that my profesor requires functions, i thought i'd have it like this. Thx for your input.
Good day:
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open ("food.txt");
outFile.open ("foodout");
char letter[30];
string item[30];
double cost[30];
const double taxrate = 0.06;
double mealprice, tax, amount_tendered,change, total;
inFile>>letter[30];
inFile>>item[30];
inFile>>cost[30];
cout<<letter<<item<<cost<<endl;
//calculate tax and total price
tax = (mealprice * taxrate);
subtotal = mealprice + tax;
//Display receipt
cout<<endl;
cout<<"Zandiago’s Z-BURGER SHACK"<<endl;
cout<<"Amount"<<mealprice<<endl;
cout<<"6 % Sales Tax"<<tax<<endl;
cout"============================================"<<endl;
cout"Total"<<total<<endl;
cout<<"Amount tendered"<<amount_tendered<<endl;
cout<<"Change"<<(amount_tendered-total)<<endl;
cout<<"Thank you for visiting"'\n';
cout<<"Zandiago's Z-Burger Shack"<<endl;
return 0;
}
How can i get the info from the infile(one data stored on top of the other) to be stored into the arrays and i have? Thx for your input.
Thx for the input. Salem, we haven't yet done struct/class, but i'll read up on it to see how i could do it. Let me make some more modifications to see how far we can go. Thx again for the assistance.
Thx for your input. So i guess something like this:
myarray[letter][item][cost];
If you look at my infile (as show before), how do i get the data from each individual line to be stored in the array?
I'm also pretty sure that your professor must have given you a specific range of which to get the 1000 numbers. By that I mean...is it a range of numbers between 1 & 5 billion??? Some steps for you and as brought out by Salem...we'll not do your assignment, but we'll guide you and when you get burned out and stuck, we'll try out best to bail you out. A few things:
1. First you'll need to create to use a C++ random generator function. i.e.
srand((unsigned int)time(NULL));
2. You'll need to create an array to store the 1000 numbers. i.e.
mynumbers[1000]
3. The average:
(Sumofnumbers/mynumbers)
4. For the maximum and minimum:
min = 32767
max = -32767
for (i=0; i<count; i++)
{
if(number[count]>max)
max = number[count];
if (number[count]<min)
min = number [count];
}//end for i
cout<<"Max = "<<max<< "and Min = "<<min<<endl;
5. Before posting in the future, chances are that your assignment has been addressed. Please search the forums for similar programs and see if you understand it. Also read the FAQ and Forum Rules to get aquainted with the forum. Welcome aboard and hope you enjoy it. Please do read up on arrays.
Good day. My infile contains the following:
TFFTFFTFFTFFTFTFTFTFFF
A33
TFFTFFTFFFFFTFTFTFFFFT
Z27
TFFTFFTFFTFFTFTFTFTFFT
X12
TFTT FTFFTFFFT FTFTFFF
H44
TFFTFFTFFTFFFFTFTFFTFF
Q19
FFFFFFFFFFFFTFTFTFFFFF
D72
TFFTFFTFFTFF FFFFFTFFF
W32
FFFTFFTFFTFFTFTFTFFTTT
Y09
TFFTFFTFFTFFTFFTTFFTTT
S44
TFFTFFTFFTFFTFTFTFTFFF
G11
FFTFFTFFTFFTFTFTTFTFFF
J21
TFFTFFFFFTFFTFTFTFTFTT
K61
TFFTFFTFFTFFTFTFTFTFT
M03
TFFTFFTFFFFFTFTFTFTFFT
P24
TFFTFFTFFTFFTFTFTFFFFT
N54
FTFFTFFTFT TFF FTFTFFF
F33
TFFTFFTFFTFFTFTFTFTFFF
Z21
TFFTFFFTTFTTFFTFTFTFTF
V39
TFFFTTFTTFTTFTFTFTTFFF
O66
TTFTFFTFFTFFTFTFTFTFFF
B29
TFFTFFTFFTFF FFTTFFTFF
J17
TFFTFFFTTTFFTFFTFTFTTT
K09
TFFTFFTFTTFTTFTFTFFTFF
L99
FFTFFTFFTFFFFTFTFTFFF
My assignment:
The history teacher at the school needs help in grading a True/False test. The
student lD’s and test answers are stored (vertically) in a file named "tftest.txt". The
first entry in the file contains answers to the test in the form
TFFTFFTTTTFFTFTFTFTFTT
All of the other entries in the file are data for a student on 2 lines:
A43
TFFTFFTT TFTFTFFTTFTTT
Note that this student did not answer question 9. The test has 22 questions and
there are not more than 50 students in the class. Each correct answer is awarded 5
points, each incorrect answer is awarded -2 points (negative) and each "no answer"
gets a value of -4 points (negative).
lt can be seen that all test scores will be a whole number.
The student in the example achieved a grade as follows:
14 correct * 5 = 70
7 incorrect * -2 = -14
1 no answer *-4 = -4
70 - 14 -4 = 52 F
His output line would look like:
A43 TFFTFFTT …