can you check my code the wrong part based on the question below
#includeusing namespace std;struct Student{ string name; double weight; double height;};int main (){ Student studentList [100]; //declare ofstream myfile; myfile.open ("studentData.txt"); ifstream infile; infile.open("studentData.txt"); //write into text file myfile<"test>"test> //close file my file.close (); return 0;}Extracted text: The BMI is calculated as: BMI = weight in kg / height in meter X height in meter. %3D Table 4 shows the BMI measurement and the BMI categories. Table 4 BMI(kg/m) Category 0- 18.5 Underweight >18.5 and <=23 normal="">23 and <=25 overweight-="" at="" risk="">25 and <=30 overweight-="" moderately="" obese="" more="" than="" 30="" overweight-="" severely="" obese="" the="" student="" data="" should="" be="" stored="" in="" a="" struct="" variable="" of="" type="" student="" which="" has="" 3="" components:="" name="" of="" type="" string,="" weight="" of="" type="" double="" and="" height="" of="" type="" double.="" a)="" write="" the="" definition="" of="" struct="" student.="" b)="" write="" a="" complete="" c++="" statements="" to="" do="" the="" following="" tasks:="" i)="" declare="" an="" array="" of="" type="" student="" of="" size="" 100.="" ii)="" write="" statements="" to="" read="" and="" write="" to="" file="" 1/o.="" iii)="" read="" all="" data="" from="" file="" student="">=30>=25>=23>
{ string name; double weight; double height;};
int main ()
{ Student studentList [100]; //declare ofstream myfile; myfile.open ("studentData.txt"); ifstream infile; infile.open("studentData.txt"); //write into text file myfile<"test>"test> //close file my file.close (); return 0;}
Extracted text: The BMI is calculated as: BMI = weight in kg / height in meter X height in meter. %3D Table 4 shows the BMI measurement and the BMI categories. Table 4 BMI(kg/m) Category 0- 18.5 Underweight >18.5 and <=23 normal="">23 and <=25 overweight-="" at="" risk="">25 and <=30 overweight-="" moderately="" obese="" more="" than="" 30="" overweight-="" severely="" obese="" the="" student="" data="" should="" be="" stored="" in="" a="" struct="" variable="" of="" type="" student="" which="" has="" 3="" components:="" name="" of="" type="" string,="" weight="" of="" type="" double="" and="" height="" of="" type="" double.="" a)="" write="" the="" definition="" of="" struct="" student.="" b)="" write="" a="" complete="" c++="" statements="" to="" do="" the="" following="" tasks:="" i)="" declare="" an="" array="" of="" type="" student="" of="" size="" 100.="" ii)="" write="" statements="" to="" read="" and="" write="" to="" file="" 1/o.="" iii)="" read="" all="" data="" from="" file="" student="">=30>=25>=23>
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here